0

I know for ansible, I can use ansible -m setup instance1 to see “facts” about the machines under management as per question: Where can I get a list of Ansible pre-defined variables?

But I am using molecule so is there as way to same for my instance1 docker container that I created via molecule

My reason is to try to understand why despite doing a gather_facts I am getting in my molecule logs ...

ok: [instance2] => {
    "ansible_default_ipv4": "VARIABLE IS NOT DEFINED!"
}

For reference here is my molecule setup ...

(.venv) [root@localhost foo]# molecule list
 Validation completed successfully.
Instance Name    Driver Name    Provisioner Name    Scenario Name    Created    Converged
---------------  -------------  ------------------  ---------------  ---------  -----------
instance1        docker         ansible             default          true       false
instance2        docker         ansible             default          true       false
instance3        docker         ansible             default          true       false




 # molecule login --host instance1
    // SNIP 
    Validation completed successfully.
[root@instance1 /]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:3c:17:4d:0b brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global docker0
       valid_lft forever preferred_lft forever
11: eth0@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever
k1eran
  • 4,492
  • 8
  • 50
  • 73
  • Please include more contextual logs than just the one error message, including optionally running at higher verbosity. There's no way we can _guess_ what is going wrong – mdaniel Nov 08 '19 at 06:51

1 Answers1

0

This task will print out the ansible_facts collection:

  tasks:
    - name: "print ansible_facts vars"
      debug: var=ansible_facts

From looking at what you posted though my suspicion is that instead of ansible_default_ipv4 you may actually want ansible_facts['default_ipv4']