Fiz todos os passos de acordo com o curso, mas o arquivo ignora meu host database. E faz apenas o wordpress.
[WARNING]: Could not match supplied host pattern, ignoring: database
PLAY [database] ****************************************************************
skipping: no hosts matched
segue meu playbook.yml
---
- hosts: database
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: wordpress_db
login_user: root
state: present
- name: 'Cria o usuário do MySQL'
mysql_user:
login_user: root
name: wordpress_user
password: 12345
priv: 'wordpress_db.*:ALL'
state: present
- 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", "mysql-server-5.6",
"python-mysqldb", "php5-mysql"]
state: latest
become: yes
- name: 'Cria o banco do MySQL'
mysql_db:
name: wordpress_db
login_user: root
state: present
- name: 'Cria o usuário do MySQL'
mysql_user:
login_user: root
name: wordpress_user
password: 12345
priv: 'wordpress_db.*:ALL'
state: present
- 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: '/var/www/wordpress/wp-config-sample.php'
dest: '/var/www/wordpress/wp-config.php'
remote_src: yes
become: yes
- name: 'Configura o wp-config com as entradas do banco de dados'
replace:
path: '/var/www/wordpress/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', value: '12345'}
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
segue também meu arquivo host
[wordpress]
192.168.1.132 ansible_user=vagrant ansible_ssh_private_key_file="--private-key .ssh/id_rsa"
[database]
192.168.1.134 ansible_user=vagrant ansible_ssh_private_key_file="--private-key .ssh/id_rsa"
Obrigado.