Olá, esta aparecendo o erro a baixo quando manda rodar o playbook.
vagrant@ubuntu-bionic:~$ ansible-playbook -i /vagrant/configs/ansible/hosts /vagrant/configs/ansible/playbook.yml
PLAY [all] ***************************************************************************
TASK [Gathering Facts] ***************************************************************
fatal: [10.0.0.191]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"failed": true, "module_stderr": "Shared connection to 10.0.0.191 closed.\r\n", "module_stdout": "/bin/sh: 1: /urs/bin/python3: not found\r\n", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127}}, "msg": "The following modules failed to execute: setup\n"}
PLAY RECAP ***************************************************************************
10.0.0.191 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Antes tava com outro problema no código do playbook mas o Thiago do outro tópico mostrou a solução, mas agora aparece esse ai de cima ... até tentei pesquisar na internet, mas como sou novo nessa área não achei solução.
Se alguém puder me ajudar eu figo agradecido
Meu arquivo HOST
[mysqlserver]
10.0.0.191
[mysqlserver:vars]
ansible_user=vagrant
ansible_ssh_private_key_file=/home/vagrant/id_bionic
ansible_python_interpreter=/urs/bin/python3
ansible_ssh-commom_args='-o StrictHostKeyChecking=no'
Meu Playbook
- hosts: all
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: /vagrant/configs/mysqld.cnf
dest: /etc/mysql/mysql.conf.d/mysqld.cnf
owner: root
group: root
mode: 0644
become: yes
notify:
- restart mysql
Meu Vagrantfile
$script_mysql = <<-SCRIPT
apt-get update && \
apt-get install -y mysql-server-5.7 && \
mysql -e "create user 'phpuser'@'%' identified by 'pass';"
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.define "mysqlserver" do |mysqlserver|
mysqlserver.vm.network "public_network", ip: "10.0.0.191"
mysqlserver.vm.provision "shell",
inline: "cat /vagrant/configs/id_bionic.pub >> .ssh/authorized_keys"
end
config.vm.define "ansible" do |ansible|
ansible.vm.network "public_network"
ansible.vm.provision "shell",
inline: "cp /vagrant/id_bionic /home/vagrant && \
chmod 600 /home/vagrant/id_bionic"
ansible.vm.provision "shell",
inline: "apt-get update && \
apt-get install -y software-properties-common && \
apt-add-repository --yes --update ppa:ansible/ansible && \
apt-get install -y ansible"
end
config.vm.define "mysqldb" do |mysql|
mysql.vm.network "public_network", ip: "10.0.0.23"
mysql.vm.provision "shell",
inline: "cat /configs/id_bionic.pub >> .ssh/authorized_keys"
mysql.vm.provision "shell", inline: $script_mysql
mysql.vm.provision "shell",
inline: "cat /configs/mysqld.cnf > /etc/mysql/mysql.conf.d/mysqld.cnf"
mysql.vm.provision "shell", inline: "service mysql restart"
mysql.vm.synced_folder "./configs", "/configs"
mysql.vm.synced_folder ".", "/vagrant", disabled: true
end
config.vm.define "phpweb" do |phpweb|
phpweb.vm.network "forwarded_port", guest: 8888, host: 8888
phpweb.vm.network "public_network", ip: "10.0.0.22"
phpweb.vm.provision "shell",
inline: "apt-get update && apt-get install -y puppet"
phpweb.vm.provision "puppet" do |puppet|
puppet.manifests_path = "./configs/manifests"
puppet.manifest_file = "phpweb.pp"
end
end
end