Configuração Vagrant
// Local das configurações Vagrant
- Estrutura A raiz do projeto possuí o arquvio Vagrantfile e os diretórios ansible e scripts:
- O arquvio Vagrantfile provisiona cada máquina virtual, vem com a definição de 5 máquinas virtuais configuradas e pode ser alterado conforme suas necessidades.
- O diretório scripts contém os scripts que providenciam as instalações e principais definições para funcionamento do Ansible no servidor e nos hosts. As máquinas virtuais definidas no arquivos Vagrantfile devem conter um script para executar esses pré requistos para funcionamento do Ansible.
- O diretório ansible contém as roles, playbook e arquivo de hosts necessários para funcionamento do Ansible
- O diretório ansible contém as roles, playbook e arquivo de hosts necessários para funcionamento do Ansible e é compartilhada para a máquina virtual servidor do Ansible. Proporsionando uma edição fora do ambiente Linux, onde é possíve, como exemplo, a utilização do VS Code para edição do playbook e roles.
Utilizando Ansible
Quando é executado o comando "vagrant up" a ultima máquina virtual a ser provisionada é o servidor Vagrant.
Quando é executado o comando "vagrant up" a ultima máquina virtual a ser provisionada é o servidor Vagrant. Este servidor definido como "vm01" no Vagrantfile executa o script "server.sh" que executa o playbook contido em "ansible/main.yml" para os hosts definidos em "ansible/servers", a execução do playbook pode ser inibida comentando a linha no script. O servidor "vm01" pode ser acessado pelo comando "vagrant ssh" onde é possível executar as alterações de playbook e roles editadas. Todos os host alterados, excluídos ou incluído do Vagrantfile devem ser alterados no arquivo ansible/servers.