From 6ec582b11df2cda489d1815e629c3374474e29f2 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Wed, 4 Sep 2024 14:08:20 +0200 Subject: [PATCH 1/2] use ansible_default_ipv4 if possible when writing /etc/hosts --- roles/etc_hosts/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/etc_hosts/tasks/main.yml b/roles/etc_hosts/tasks/main.yml index e0f3f8c68..8141a3705 100644 --- a/roles/etc_hosts/tasks/main.yml +++ b/roles/etc_hosts/tasks/main.yml @@ -3,7 +3,7 @@ lineinfile: dest: /etc/hosts regexp: ".*{{ item.replace('.', '-') }}$" - line: "{{ hostvars[item].ansible_host }} {{ item.replace('.', '-') }}.{{ etc_hosts_domain }} {{ item.replace('.', '-') }}" + line: "{{ ansible_default_ipv4['address'] | default(hostvars[item].ansible_host) }} {{ item.replace('.', '-') }}.{{ etc_hosts_domain }} {{ item.replace('.', '-') }}" state: present when: hostvars[item].ansible_host is defined become: yes From 115276df1128291a26c766ed068bc477922c1bba Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Thu, 5 Sep 2024 11:55:43 +0200 Subject: [PATCH 2/2] Force Ansible 2.x compatiblity mode in Vagrant In some setups it miss-detects the Ansible version and uses 1.8 compatiblity mode, which doesn't work properly with modern Ansible. --- vagrant/lib/forklift/box_distributor.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/vagrant/lib/forklift/box_distributor.rb b/vagrant/lib/forklift/box_distributor.rb index 86afe1a33..d32c0ea64 100644 --- a/vagrant/lib/forklift/box_distributor.rb +++ b/vagrant/lib/forklift/box_distributor.rb @@ -190,6 +190,7 @@ def configure_ansible(machine, ansible, box_name) [playbooks].flatten.each_with_index do |playbook, index| machine.vm.provision("main#{index}", type: 'ansible') do |ansible_provisioner| + ansible_provisioner.compatibility_mode = '2.0' ansible_provisioner.playbook = playbook ansible_provisioner.extra_vars = ansible['variables'] ansible_provisioner.groups = @ansible_groups