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

ansible.posix.synchronize attempts to uses IPv6 on IPv4 only system #531

Open
BloodBlight opened this issue Feb 16, 2024 · 1 comment
Open

Comments

@BloodBlight
Copy link

SUMMARY

When using ansible.posix.synchronize to pull from a target that is dual stacked with both IPv4 and IPv6, where the control server only has IPv4 will fail with "No route to host" as it defaults to IPv6.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible.posix.synchronize

ANSIBLE VERSION
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Oct  6 2023, 09:53:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
COLLECTION VERSION

This command fails, I assume becuase this is a RHEL 7 box, but running the newest version available:

ansible.posix:1.5.4

This is the only module installed.

CONFIGURATION
NULL

This is a new install.

OS / ENVIRONMENT
Managment:
NAME="Red Hat Enterprise Linux Workstation"
VERSION="7.9 (Maipo)"
IPv4 Stack

Target:
NAME="Red Hat Enterprise Linux"
VERSION="8.8 (Ootpa)"
Dual Stacked IPv4 & IPv6
STEPS TO REPRODUCE

ansible-playbook -i hosts collect_network_info.yml

 - name: Collect Network Interface and VLAN Configurations
   hosts: all_servers
   gather_facts: yes
   tasks:
     - name: Gather network facts
       ansible.builtin.setup:
         gather_subset: network
     - name: Save network facts to a file
       copy:
         content: "{{ ansible_all_ipv4_addresses }}"
         dest: "/tmp/network_facts.json"
     - name: Fetch facts from server.
       ansible.posix.synchronize:
         mode: pull
         src: rsync://{{ inventory_hostname }}/tmp/network_facts.json
         dest: "/root/Ansible/facts/{{ inventory_hostname }}_network_facts.json"
         dest: /root/Ansible/facts/
EXPECTED RESULTS

As the local host only has IPv4, and the logs seems to show the IPv4 in the connection error, I would assume it should use that.

ACTUAL RESULTS

The command actually uses the IPv6 address after resolving the IPv4 address.

#REDACTED LOG:
fatal: [%%HOST NAME%%]: FAILED! => {
    "changed": false,
    "cmd": "/bin/rsync --delay-updates -F --compress --archive --out-format='<<CHANGED>>%i %n%L' rsync://%%HOST NAME%%/tmp/network_facts.json /root/Ansible/facts/",
    "invocation": {
        "module_args": {
            "_local_rsync_password": null,
            "_local_rsync_path": "rsync",
            "_substitute_controller": false,
            "archive": true,
            "checksum": false,
            "compress": true,
            "copy_links": false,
            "delay_updates": true,
            "delete": false,
            "dest": "/root/Ansible/facts/",
            "dest_port": null,
            "dirs": false,
            "existing_only": false,
            "group": null,
            "link_dest": null,
            "links": null,
            "mode": "pull",
            "owner": null,
            "partial": false,
            "perms": null,
            "private_key": "/root/.ssh/id_rsa",
            "recursive": null,
            "rsync_opts": [],
            "rsync_path": null,
            "rsync_timeout": 0,
            "set_remote_user": true,
            "src": "rsync://%%HOST NAME%%/tmp/network_facts.json",
            "ssh_args": null,
            "ssh_connection_multiplexing": false,
            "times": null,
            "verify_host": false
        }
    },
    "msg": "rsync: failed to connect to %%HOST NAME%% (%%Hosts IPv4 Address%%): No route to host (113)\nrsync: failed to connect to %%HOST NAME%% (%%Hosts !!IPv6!! Address%%): Network is unreachable (101)\nrsync error: error in socket IO (code 10) at clientserver.c(126) [Receiver=3.1.2]\n",
    "rc": 10
}
FINAL NOTES

I am new to Ansible, sorry if I am missing something obvious.

@BloodBlight
Copy link
Author

Correction, seems to be an issue with the documentation maybe?

Tried switching to IPs, and it gave the same error!

Using this works:

         mode: pull
         src: /tmp/network_facts.json
         dest: "/root/Ansible/facts/{{ inventory_hostname }}_network_facts.json"
         dest: /root/Ansible/facts/

Is this a problem with the documentation?
https://docs.ansible.com/ansible/latest/collections/ansible/posix/synchronize_module.html

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

No branches or pull requests

1 participant