1
resposta

Windows->Vagrant->Ansible

Boa tarde pessoal, ainda não consegui rodar o primeiro exercício do surdo de Ansible.

A Infra que estou usando é:

Minha máquina Windows 10 Virtual Box -> VM (LInux com o Ansible) Quando rodo o comando: ansible wordpress -u vagrant --private-key .vagrant\machines\ansible\virtualbox\private_key -i /vagrant/hosts -m shell -a 'echo Hello, Word'

**Está aparecendo essa mensagem:**
 [WARNING] Ansible is in a world writable directory (/vagrant), ignoring it as an ansible.cfg source.
192.168.0.201 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: no such identity: /vagrant/.vagrantmachinesansiblevirtualboxprivate_key: No such file or directory\r\nvagrant@192.168.0.201: Permission denied (publickey).\r\n",
    "unreachable": true
}

Meu Vagrant file:

Vagrant.configure("2") do |config|
    config.vm.provider "virtualbox" do |vb|
        vb.memory = 512
        vb.cpus = 1
    end
    config.vm.define "ansible" do |ansible|
        config.vm.provider "virtualbox" do |vb|
            vb.memory = 1024
            vb.cpus = 1
        end
        config.vm.box = "ubuntu/bionic64"
        ansible.vm.network "public_network", ip: "192.168.0.200"
        ansible.vm.provision "shell", inline: "echo INICIANDO a instalação do ANSIBLE"
        ansible.vm.provision "shell", inline: "apt update"
        ansible.vm.provision "shell", inline: "apt install ansible -y"
        # ansible.vm.provision "shell", inline: "apt-get install linuxbrew-wrapper -y"
        ansible.vm.provision "shell", inline: "cat /vagrant/id_bionic.pub >> .ssh/authorized_keys"
        ansible.vm.provision "shell", inline: "cp /vagrant/id_bionic /home/vagrant && \
                                                chmod 600 /home/vagrant/id_bionic"
    end
    config.vm.define "wordpress" do |wordpress|
        config.vm.box = "ubuntu/bionic64"
        wordpress.vm.network "public_network", ip: "192.168.0.201"
        wordpress.vm.provision "shell", inline: "echo INICIANDO a atualização do WORDPRESS"
        wordpress.vm.provision "shell", inline: "apt update"
        wordpress.vm.provision "shell", inline: "cat /vagrant/id_bionic.pub >> .ssh/authorized_keys"
    end
end

Poderiam me dar uma luz de como avançar ?

1 resposta

Fiz um novo teste e ainda não consegui:

vagrant@ubuntu-bionic:~$ ansible wordpress -i /vagrant/hosts -m shell -a 'echo Hello, world'
192.168.0.201 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: vagrant@192.168.0.201: Permission denied (publickey).\r\n",
    "unreachable": true
}