Boa tarde, pessoal! estou com dificuldades de subir o wordpress, ele da erro de conexão com o banco. Segue o erro:
''Error establishing a database connection''
Segue meu código do arquivo provisioning.yml:
---
- hosts: database
handlers:
- name: restart mysql
service:
name: mysql
state: restarted
become: yes
tasks:
- name: 'Instala pacotes de dependencia do sistema operacional'
apt:
update_cache: yes
cache_valid_time: 3600 #1 hora
name: "{{ item }}"
state: latest
become: yes
with_items:
- mysql-server-5.6
- python-mysqldb
- name: 'Cria o banco no MySQL'
mysql_db:
name: wordpress_db
login_user: root
state: present
- name: 'Cria usuario no MySQL'
mysql_user:
login_user: root
name: wordpress_user
password: 12345
priv: 'wordpress_db.*:ALL'
state: present
host: '{{ item }}'
with_items:
- 'localhost'
- '127.0.0.1'
- '192.168.56.8'
- name: 'Configura MySQL para aceitar conexões 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 do sistema operacional'
apt:
update_cache: yes #atualizando o package list
cache_valid_time: 3600 #1 hora
name: "{{ item }}"
state: latest
become: yes
with_items:
- php5
- apache2
- libapache2-mod-php5
- php5-gd
- libssh2-php
- php5-mcrypt
- php5-mysql
- name: 'Baixa o arquivo de instalacao do Wordpress'
get_url:
url: 'https://wordpress.org/wordpress-5.0.tar.gz'
dest: '/tmp/wordpress.tar.gz'
mode: 0440
become: yes
- 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 }}"
backup: yes
with_items:
- { regex: 'database_name_here', value: 'wordpress_db'}
- { regex: 'username_here', value: 'wordpress_user'}
- { regex: 'password_here', value: '12345'}
- { regex: 'localhost', value: '192.168.56.7'}
become: yes
- name: 'Configura Apache para servir o Wordpress'
copy:
src: 'files/000-default.conf'
dest: '/etc/apache2/sites-available/000-default.conf'
notify:
- restart apache
become: yes