Boa tarde pessoal,
Eu gostaria de saber se podem me ajudar com uma dúvida. Hoje coloquei meu Vagrantfile para subir com alguns steps, como podem ver abaixo:
VAGRANT FILE
# criando VMs MySql server e PHP, com box Linux bionic
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
# define servidor PHP
config.vm.define "phpweb" do |phpweb|
phpweb.vm.network "forwarded_port", guest:8888, host:8888
phpweb.vm.network "public_network", ip: "10.0.0.72"
# instala puppet no servidor php
phpweb.vm.provision "shell", inline: "apt-get update && apt-get install puppet -y"
# configura puppet no servidor php e chama manifest_file
phpweb.vm.provision "puppet" do |puppet|
puppet.manifests_path = "./configs/manifests"
puppet.manifest_file = "phpweb.pp"
end
end
# define MySQL server
config.vm.define "mysqlserver" do |mysqlserver|
mysqlserver.vm.network "public_network", ip: "10.0.0.73"
mysqlserver.vm.provision "shell", inline: "cat /vagrant/configs/id_bionic.pub >> .ssh/authorized_keys"
end
# Run Ansible playbook from the Vagrant Host
config.vm.provision "ansible" do |ansible|
ansible.playbook = "./configs/ansible/playbook.yml"
end
end
O Vagrant segue os steps normalmente até a criação da phpweb VM, quando deveria chamar o step que instala o puppet;
# instala puppet no servidor php
phpweb.vm.provision "shell", inline: "apt-get update && apt-get install puppet -y"
O step do Ansible é chamado;
# Run Ansible playbook from the Vagrant Host
config.vm.provision "ansible" do |ansible|
ansible.playbook = "./configs/ansible/playbook.yml"
end
O playbook roda sem errors e tudo funciona, porém a ordem de execução correta seria somente chamar o playbook depois de todos os outros step anteriores serem concluídos, saberiam dizer qual o problema ?
* Playbook.yml *
---
- hosts: mysqlserver
handlers:
- name: restart mysql
service:
name: mysql
state: restarted
become: yes
tasks:
- name: 'Instalar MySQL Server'
apt:
update_cache: yes
cache_valid_time: 3600 #1 hora
name: ["mysql-server-5.7", "python3-mysqldb"]
state: latest
become: yes
- name: 'Criar usuario no MySQL'
mysql_user:
login_user: root
name: phpuser
password: pass
priv: '*.*:ALL'
host: '%'
state: present
become: yes
- name: 'Copiar arquivo mysqld.cnf'
copy:
src: /home/eddie/devops/ambient_dev/bionic/configs/mysqld.cnf
dest: /etc/mysql/mysql.conf.d/mysqld.cnf
owner: root
group: root
mode: 0644
become: yes
notify:
- restart mysql
** hosts file **
[mysqlserver]
10.0.0.73
[mysqlserver:vars]
ansible_user=vagrant
ansible_ssh_private_key_file=/home/vagrant/id_bionic
ansible_python_interpreter=/usr/bin/python3
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
obrigado, Edvaldo