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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Sep 4, 2024

No description provided.

@@ -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.

In some setups it miss-detects the Ansible version and uses 1.8
compatiblity mode, which doesn't work properly with modern Ansible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants