I have a machine, that is accessible via ipv6 only. It is setup for ssh with rsa key. Now I'd like to manage it with ansible. Unfortunately, this is not covered in the inventory documentation.

So I tried the following permutations:

  • docker_test ansible_host=fe80::88ea:e002:b409:4be0
  • docker_test ansible_host=[fe80::88ea:e002:b409:4be0]
  • docker_test ansible_host=\[fe80::88ea:e002:b409:4be0\]

None of this worked out.

For comparison I add my .ssh/config entry:

Host docker_host
    AddressFamily inet6
    HostName fe80::88ea:e002:b409:4be0
    BindAddress fe80::3e6b:335a:d2f7:3a75%enp3s0

I found two closed bug in the issue tracking system,which indicate the problem being at least partially solved: 3879, 3888

Any advise on this topic is highly appreciated.

  • Did you try to use an inventory file? And please tell us the errors you get. – guntbert Jul 30 at 19:37
  • Yes, I did try using the inventory file. The three permutations posted originated from there. The exceptions are rather vague stating either a wrong format in the inventory file or a false argument for the ssh client. – tgr Jul 31 at 6:25
  • The IPv6 address is missing the mandatory scope ID. Of course you should avoid using link-local addresses whenever possible. – Michael Hampton Aug 8 at 14:43
up vote 3 down vote accepted

This blog post covers all of the methods:

excerpt - Host names and patterns in Ansible 2

Inventory hostnames

Ansible 2 requires inventory hostnames to be valid IPv4/IPv6 addresses or hostnames (i.e., x.example.com or x, but not x..example.com or x--). As an extension, it accepts Unicode word characters in hostname labels. Any mistakes result in specific parsing errors, not mysterious failures during execution.

Inventory hostnames may also use alphabetic or numeric ranges to define more than one host. For example, foo[1:3] defines foo1 through foo3, while foo[x:z:2] expands to fox and foz. Addresses may use numeric ranges: 192.0.2.[3:42].

IPv6 addresses

A number of problems with the parsing of IPv6 addresses have also been fixed, and their behaviour has been made consistent across the inventory (.ini files) and in playbooks (e.g., in hosts: lines and with add_host).

All of the recommended IPv6 address notations (from spelling out all 128 bits to the various compressed forms) are supported. Addresses with port numbers must be written as [addr]:port. One can also use hexadecimal ranges to define multiple hosts in inventory files, e.g. 9876::[a:f]:2.

A couple of small but necessary bugfixes go hand-in-hand with the parsing changes, and fix problems with passing IPv6 addresses to ssh and to rsync. Taken together, these changes make it possible to use IPv6 in practice with Ansible.

Therefore patterns such as these IPv6's would be allowed:

  • fully specified 128 bit address
  • [addr]:port
  • hexadecimal ranges - 9876::[a:f]:2
  • various forms of compressing ranges - FF01::[1:6]

Simplified examples:

# IPv6 Address                                # Simplified Notation
-----------------------------------------     ----------------------------
- FF01:0000:0000:0000:0000:0000:0000:0001     - FF01::1
- 2031:0000:130F:0000:0000:09C0:876A:130B     - 2031:0:130F::9C0:876A:130B
- 0000:0000:0000:0000:0000:0000:0000:0001     - ::1
- FE80:0000:0000:5EFE:0192.0168.0001.0123     - FE80::5EFE:192.168.1.123
- FE80:0000:0000:0000:1585:4868:495F:D521     - FE80::1585:4868:495F:D521

References

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.