Desculpa, mas faz dois dias que procuro a solução do erro no -copy até desiti de afazer o restante da aula. O Ansible reclama que há um erro no -copy, mas ja executei de varias formas e não se resolve. e nem achei uma solução.
ERROR ANSIBLE:
reis@reis:~/AmbienteDevOps/ansible$ ansible-playbook provisioning.yml -i hosts [WARNING]: While constructing a mapping from /home/reis/AmbienteDevOps/ansible/provisioning.yml, line 57, column 7, found a duplicate dict key (become). Using last defined value only. ERROR! conflicting action statements: copy, replace
The error appears to be in '/home/reis/AmbienteDevOps/ansible/provisioning.yml': line 57, column 7, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- copy:
^ here
ARQUIVO: provisioning.yml
hosts: all tasks:
name: 'isntall dependencia package operate system' apt:
# dessa forma se instala mais pacotes em menor numero de linhas
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: 'BANCO E USER BANCO SQL' mysql_db: name: wordpress_db login_user: root state: present
- name: 'criar user para o banco e dar permissão'
mysql_user:
login_user: root
name: reis
password: 12345
priv: 'wordpress_db.*:ALL'
state: absent
- 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, é preciso o remoe yes para confirmar mv remota'
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
replace:
path: '/var/www/wordpress/wp-config.php'
regexp: "{{item.regexp}}"
replace: "{{item.value}}"
with_items:
- {regexp:'database_name_here', value: 'wordpress_db'}
- {regexp:'username_here', value: 'wordpress_user'}
- {regexp:'password_here', value: '12345'}
become: yes
# forma primaria de instalação. necessario instalar 1 por 1
# - name: 'Instala o PHP5'
# apt:
# update_cache: yes #atualizando o package list
# cache_valid_time: 3600 #cache valido por 1 hora
# name: php5
# state: latest
# become: yes
# - name: 'Instala o Apache2'
# apt:
# name: apache2
# state: latest
# become: yes
# - name: 'Instala o modphp'
# apt:
# name: libapache2-mod-php5
# state: latest
# become: yes