Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ansible_default_ipv4 if possible when writing /etc/hosts #1854

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion roles/etc_hosts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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('.', '-') }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ansible_host is 127.0.0.1 when using VirtualBox, which confuses our installer (rightfully)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested, so the box is not spinning up with just this changes, but I tried to include the changes we tried to make earlier that is:

Adding 'compatibility_mode' => '2.0' in this file vagrant/lib/forklift/box_factory.rb#L111 and ansible_provisioner.compatibility_mode = '2.0' in vagrant/lib/forklift/box_distribution.rb#L193

This is doing our work but I still see this message:

Vagrant gathered an unknown Ansible version:


and falls back on the compatibility mode '1.8'.

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the one to box distributor is needed, the other should not (I pushed it in here, just to be sure)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked at first but I tried to up it again and seeing the same thing:

TASK [foreman_installer : Run installer] ***************************************
fatal: [centos9-stream-foreman-nightly]: FAILED! => changed=true 
  cmd: |-
    foreman-installer -v --no-colors   --scenario foreman  --foreman-initial-admin-password changeme
  delta: '0:00:02.888077'
  end: '2024-09-10 18:18:49.890471'
  msg: non-zero return code
  rc: 20
  start: '2024-09-10 18:18:47.002394'
  stderr: Reverse DNS failed. Looking up 127.0.0.1 gave localhost, expected to match centos9-stream-foreman-nightly.akumari.example.com
  stderr_lines: <omitted>
  stdout: |-
    2024-09-10 18:18:47 [NOTICE] [root] Loading installer configuration. This will take some time.
    2024-09-10 18:18:49 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
    2024-09-10 18:18:49 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
    Your system does not meet configuration criteria
  stdout_lines: <omitted>

PLAY RECAP *********************************************************************
centos9-stream-foreman-nightly : ok=20   changed=1    unreachable=0    failed=1    skipped=19   rescued=0    ignored=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

state: present
when: hostvars[item].ansible_host is defined
become: yes
Expand Down
1 change: 1 addition & 0 deletions vagrant/lib/forklift/box_distributor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading