diff --git a/README.md b/README.md index 9408413..5d181a8 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,11 @@ What things you need to run this Ansible playbook : * [Vagrant](https://www.vagrantup.com/docs/installation/) must be installed on your computer * Update the Vagrant file based on your computer (CPU, memory), if needed * Update the operating system to deploy in the Vagrant file (default: Ubuntu) +* Install the [Vagrant HostManager plugin](https://github.com/devopsgroup-io/vagrant-hostmanager) : + +``` +$ vagrant plugin install vagrant-hostmanager +``` * Download the Ansible requirements: ```bash @@ -42,6 +47,7 @@ Current machine states: puppet01 running (virtualbox) puppet02 running (virtualbox) +puppet03 running (virtualbox) ``` If everything run as expected, you should have Puppet installed and configured on the Vagrant instance. diff --git a/Vagrantfile b/Vagrantfile index e8470a3..58c200c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,7 +10,7 @@ SUPPORTED_OS = { # Vagrant instance management $os = "centos" -$num_instances = 2 +$num_instances = 3 $instance_name_prefix = "puppet" $vm_memory = 2048 $vm_cpus = 2 @@ -38,6 +38,13 @@ end Vagrant.configure("2") do |config| + # Configure hosts file + config.hostmanager.enabled = true + config.hostmanager.manage_host = true + config.hostmanager.manage_guest = true + config.hostmanager.ignore_private_ip = false + config.hostmanager.include_offline = true + # always use Vagrants insecure key config.ssh.insert_key = false config.ssh.username = SUPPORTED_OS[$os][:user] diff --git a/roles/puppet/tasks/main.yml b/roles/puppet/tasks/main.yml index 618c952..a164d21 100644 --- a/roles/puppet/tasks/main.yml +++ b/roles/puppet/tasks/main.yml @@ -3,12 +3,6 @@ - name: PUPPET | Include OS-specific variables include_vars: "{{ ansible_os_family }}.yml" -- name: PUPPET | Configure hosts file - lineinfile: - path: /etc/hosts - line: "{{ hostvars[item]['ip'] }} {{ item }}" - loop: "{{ groups['puppet_server'] }}" - - name: PUPPET | Include OS-specific tasks include_tasks: "{{ ansible_os_family }}.yml"