Skip to content

Instantly share code, notes, and snippets.

@jruels
Last active December 31, 2015 11:19
Show Gist options
  • Save jruels/7978868 to your computer and use it in GitHub Desktop.
Save jruels/7978868 to your computer and use it in GitHub Desktop.
TASK: [magento | Copy Magento local.xml config] *******************************
fatal: [ansibleweb1] => {'msg': "One or more undefined variables: 'dict object' has no attribute 'ansible_eth0'", 'failed': True}
fatal: [ansibleweb1] => {'msg': "One or more undefined variables: 'dict object' has no attribute 'ansible_eth0'", 'failed': True}
#interface
iface: eth0
#db_ip
mag_db_ip: "{{ hostvars['ansibledb1']['ansible_' + iface].ipv4.address }}"
#app server's IP
mag_app_ip: "{{ hostvars['ansibleweb1']['ansible_' + iface].ipv4.address }}"
<connection>
<host><![CDATA[{{ mag_db_ip }}]]></host>
<username><![CDATA[{{ mag_db_user }}]]></username>
<password><![CDATA[{{ mag_db_password }}]]></password>
<dbname><![CDATA[{{ mag_db_name }}]]></dbname>
<initStatements><![CDATA[SET NAMES utf8]]></initStatements>
<model><![CDATA[mysql4]]></model>
<type><![CDATA[pdo_mysql]]></type>
<pdoType><![CDATA[]]></pdoType>
<active>1</active>
</connection>
---
- name: Download Magento Downloader
get_url: url=http://www.magentocommerce.com/downloads/assets/{{ mag_version }}/magento-{{ mag_version }}.tar.gz dest=/srv/magento-{{ mag_version }}.tar.gz
- name: Extract Archive
command: chdir=/srv/ /bin/tar xvf magento-{{ mag_version }}.tar.gz creates=/srv/magento
- name: Change ownership of Magento installation
file: path=/srv/magento/ owner=www-data group=www-data state=directory recurse=yes
- name: Copy Magento local.xml config
template: src=local.xml.j2 dest=/srv/magento/app/etc/local.xml owner=www-data group=www-data
---
- name: Install required packages for apt_repository
apt: name={{ item }} state=present
with_items:
- python-apt
- python-pycurl
- name: Add MySQL 5.6 PPA
apt_repository: repo='ppa:ondrej/mysql-5.6' state=present
- name: Install Mysql package
apt: name={{ item }} state=present
with_items:
- mysql-server-5.6
- python-mysqldb
- name: Create Mysql configuration file
template: src=my.cnf.j2 dest=/etc/mysql/my.cnf
notify:
- restart mysql
- name: Start Mysql Service
service: name=mysql state=started enabled=true
- name: Create Magento database
mysql_db: name={{ mag_db_name }} state=present
- name: Create Magento database user
mysql_user: name={{ mag_db_user }} password={{ mag_db_password }} priv={{ mag_db_name }}.*:ALL host={{ mag_app_ip }} state=present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment