vagranfile
local: /home/user/workspace/alura/formacao-devops/ansible/workspace_vagrant/Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 1
end
config.vm.define "control_node" do |control_node|
control_node.vm.provider "virtualbox" do |v|
v.name = "alura-ansible-control-node"
end
control_node.vm.network "public_network", ip: "192.168.1.100", bridge: "wlp2s0"
control_node.vm.hostname = "control-node"
control_node.vm.provision "shell", path: "script_control_node.sh"
end
config.vm.define "node_wordpress" do |node_wordpress|
node_wordpress.vm.provider "virtualbox" do |v|
v.name = "alura-ansible-node-wordpress"
end
node_wordpress.vm.network "public_network", ip: "192.168.1.101", bridge: "wlp2s0"
node_wordpress.vm.hostname = "node-wordpress"
node_wordpress.vm.provision "shell", path: "script_node.sh"
end
end
hosts
local: /home/user/workspace/alura/formacao-devops/ansible/workspace_vagrant/hosts
[group_node_wordpress]
192.168.1.101
provisioning.yml
local: /home/user/workspace/alura/formacao-devops/ansible/workspace_vagrant/workspace_ansible/provisioning.yml
---
- hosts: all
tasks:
- name: 'Task instala o PHP5'
apt:
name: php5
state: latest
become: yes
- name: 'Task instala o Apache2'
apt:
name: apache2
state: latest
become: yes
- name: 'Task instala o ModPHP'
apt:
name: libapache2-mod-php5
state: latest
become: yes
script_control_node.sh
local: /home/user/workspace/alura/formacao-devops/ansible/workspace_vagrant/script_control_node.sh
#!/bin/bash
sudo apt-get update && \
sudo apt install ansible -y && \
sudo apt-get install -y fish && \
sudo apt-get install -y python3
~
script_node.sh
local: /home/user/workspace/alura/formacao-devops/ansible/workspace_vagrant/script_node.sh
#!/bin/bash
sudo apt-get update && \
sudo apt install ansible -y && \
sudo apt-get install -y fish && \
sudo apt-get install -y python3