Esse é o erro.
TASK [Cria o usuário do MySQL] *****************************************************************************************************************************************************
fatal: [192.168.1.134]: FAILED! => {"msg": "'wp_host_ip' is undefined"}
segue meu playbook
---
- hosts: database
handlers:
- name: restart mysql
service:
name: mysql
state: restarted
become: yes
tasks:
- name: 'instala pacotes de dependencia no sistema operacional'
apt:
name: ["mysql-server-5.6","python-mysqldb"]
state: latest
become: yes
- name: 'Cria o banco do MySQL'
mysql_db:
name: "{{ wp_db_name }}"
login_user: root
state: present
- name: 'Cria o usuário do MySQL'
mysql_user:
login_user: root
name: "{{ wp_username }}"
password: "{{ wp_user_password }}"
priv: "{{ wp_db_name }}.*:ALL"
state: present
host: "{{ item }}"
with_items:
- 'localhost'
- '127.0.0.1'
- "{{ wp_host_ip }}"
- name: 'Configura MySQL para aceitar conexoes remotas'
copy:
src: 'files/my.cnf'
dest: '/etc/mysql/my.cnf'
become: yes
notify:
- restart mysql
- hosts: wordpress
handlers:
- name: restart apache
service:
name: apache2
state: restarted
become: yes
tasks:
- name: 'instala pacotes de dependencia no sistema operacional'
apt:
name: ["php5", "apache2", "libapache2-mod-php5", "php5-gd", "libssh2-php", "php5-mcrypt", "php5-mysql"]
state: latest
become: yes
- name: 'Baixa o arquivo de instalacao do Wordpress'
get_url:
url: 'https://wordpress.org/latest.tar.gz'
dest: '/tmp/wordpress.tar.gz'
- name: 'Descompacta o wordpress'
unarchive:
src: '/tmp/wordpress.tar.gz'
dest: /var/www/
remote_src: yes
become: yes
- copy:
src: "{{ wp_installation_dir }}/wp-config-sample.php"
dest: "{{ wp_installation_dir }}/wp-config.php"
remote_src: yes
become: yes
- name: 'Configura o wp-config com as entradas do banco de dados'
replace:
path: "{{ wp_installation_dir }}/wp-config.php"
regexp: "{{ item.regex }}"
replace: "{{ item.value }}"
with_items:
- { regex: 'database_name_here', value: 'wordpress_db'}
- { regex: 'username_here', value: 'wordpress_user'}
- { regex: 'password_here', "{{ wp_user_password }}"}
- { regex: 'localhost', value: "{{ wp_db_ip }}"}
become: yes
- name: 'Configura o apache para servir o wordpress'
copy:
src: '/vagrant/files/000-default.conf'
dest: '/etc/apache2/sites-available/000-default.conf'
remote_src: yes
become : yes
notify:
- restart apache
e meus arquivos yml:
---
wp_username: wordpress_user
wp_db_name: wordpress_db
wp_user_password: 12345
wp_installation_dir: '/var/www/wordpress'
Arquivos wordpress.yml e database.yml
---
wp_host_ip: '192.168.1.132'
---
wp_db_ip: '192.168.1.134'