Juniper/contrail-ansible-deployer

Error "dict object' has no attribute 'ansible_hostname"

Opened this issue · 3 comments

I tried to add new compute at my existing openstack+tungsten but it failed. My new IP for my new compute is 10.0.141.60. Below are my instances.yaml

provider_config:
bms:
domainsuffix: local
ssh_user: root
ssh_pwd: P@ssw0rd
ntpserver: 1.id.pool.ntp.org

instances:
tungsten:
ip: 10.0.141.53
provider: bms
roles:
config:
config_database:
control:
analytics_database:
analytics:
webui:
openstack:
ip: 10.0.141.58
provider: bms
roles:
openstack:
compute:
ip: 10.0.141.59
provider: bms
roles:
openstack_compute:
vrouter:
compute2:
ip: 10.0.141.60
provider: bms
roles:
openstack_compute:
vrouter:

global_configuration:
CONTAINER_REGISTRY: opencontrailnightly
REGISTRY_PRIVATE_INSECURE: True

contrail_configuration:
UPGRADE_KERNEL: true
CONTRAIL_CONTAINER_TAG: latest
CONTRAIL_VERSION: latest
CLOUD_ORCHESTRATOR: openstack
CONFIG_NODEMGR__DEFAULTS__minimum_diskGB: 2
DATABASE_NODEMGR__DEFAULTS__minimum_diskGB: 2
CONFIG_DATABASE_NODEMGR__DEFAULTS__minimum_diskGB: 2
ENCAP_PRIORITY: "VXLAN,MPLSoUDP,MPLSoGRE"

kolla_config:
kolla_globals:
enable_haproxy: no
enable_ironic: no
enable_swift: no

kolla_passwords:
keystone_admin_password: c0ntrail123

when I execute the "ansible-playbook -i inventory/ -e orchestrator=openstack playbooks/configure_instances.yml" I got error

TASK [instance : Build hosts file with domain suffix when provided] **************************************************************************************************************************
ok: [10.0.141.53] => (item=10.0.141.53)
ok: [10.0.141.58] => (item=10.0.141.53)
ok: [10.0.141.60] => (item=10.0.141.53)
ok: [10.0.141.53] => (item=10.0.141.58)
ok: [10.0.141.58] => (item=10.0.141.58)
ok: [10.0.141.60] => (item=10.0.141.58)
ok: [10.0.141.53] => (item=10.0.141.60)
fatal: [10.0.141.53]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ansible_hostname'\n\nThe error appears to have been in '/root/contrail-ansible-deployer/playbooks/roles/instance/tasks/install_software_Linux.yml': line 95, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: "Build hosts file with domain suffix when provided"\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no attribute 'ansible_hostname'"}
ok: [10.0.141.58] => (item=10.0.141.60)
fatal: [10.0.141.58]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ansible_hostname'\n\nThe error appears to have been in '/root/contrail-ansible-deployer/playbooks/roles/instance/tasks/install_software_Linux.yml': line 95, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: "Build hosts file with domain suffix when provided"\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no attribute 'ansible_hostname'"}
ok: [10.0.141.60] => (item=10.0.141.60)
fatal: [10.0.141.60]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ansible_hostname'\n\nThe error appears to have been in '/root/contrail-ansible-deployer/playbooks/roles/instance/tasks/install_software_Linux.yml': line 95, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: "Build hosts file with domain suffix when provided"\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no attribute 'ansible_hostname'"}
to retry, use: --limit @/root/contrail-ansible-deployer/playbooks/configure_instances.retry

PLAY RECAP ***********************************************************************************************************************************************************************************
10.0.141.53 : ok=24 changed=5 unreachable=0 failed=1
10.0.141.58 : ok=24 changed=6 unreachable=0 failed=1
10.0.141.59 : ok=0 changed=0 unreachable=1 failed=0
10.0.141.60 : ok=26 changed=5 unreachable=0 failed=1
localhost : ok=41 changed=4 unreachable=0 failed=0

for node 10.0.141.59 unreachable is because I shut it down in purpose.

I use ansible 2.4.2 and centos 7.5

[root@localhost ~]# ansible --version
ansible 2.4.2.0
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 = /usr/bin/ansible
python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@localhost ~]# uname -r
3.10.0-862.14.4.el7.x86_64

same error for me when I execute the "ansible-playbook -i inventory/ -e orchestrator=openstack playbooks/configure_instances.yml"

TASK [configure_instances : Build hosts file for rabbitmq with domain suffix] *** skipping: [10.236.98.131]

TASK [configure_instances : Build hosts file for rabbitmq without domain suffix] ***
skipping: [10.236.98.131]

TASK [configure_instances : Build hosts file for rabbitmq without domain suffix] ***
skipping: [10.236.98.131]

TASK [configure_instances : Build hosts file with domain suffix when provided] ***
changed: [10.236.98.131] => (item=10.236.98.131)
fatal: [10.236.98.131]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ansible_hostname'\n\nThe error appears to have been in '/root/contrail-ansible-deployer/playbooks/roles/configure_instances/tasks/install_software_Linux.yml': line 133, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: "Build hosts file with domain suffix when provided"\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no attribute 'ansible_hostname'"}
to retry, use: --limit @/root/contrail-ansible-deployer/playbooks/configure_instances.retry

PLAY RECAP *********************************************************************
10.236.98.131 : ok=26 changed=5 unreachable=0 failed=1
10.236.98.132 : ok=0 changed=0 unreachable=1 failed=0
localhost : ok=10 changed=2 unreachable=0 failed=0

[root@kvm-r04-31 contrail-ansible-deployer]# ping 10.236.98.132
PING 10.236.98.132 (10.236.98.132) 56(84) bytes of data.
64 bytes from 10.236.98.132: icmp_seq=1 ttl=63 time=0.198 ms
64 bytes from 10.236.98.132: icmp_seq=2 ttl=63 time=0.182 ms
64 bytes from 10.236.98.132: icmp_seq=3 ttl=63 time=0.186 ms
^C
--- 10.236.98.132 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.182/0.188/0.198/0.017 ms
[root@kvm-r04-31 contrail-ansible-deployer]#
[root@kvm-r04-31 contrail-ansible-deployer]# ping 10.236.98.131
PING 10.236.98.131 (10.236.98.131) 56(84) bytes of data.
64 bytes from 10.236.98.131: icmp_seq=1 ttl=64 time=0.051 ms
64 bytes from 10.236.98.131: icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from 10.236.98.131: icmp_seq=3 ttl=64 time=0.033 ms
^C
--- 10.236.98.131 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.033/0.040/0.051/0.010 ms
[root@kvm-r04-31 contrail-ansible-deployer]#

[root@kvm-r04-31 contrail-ansible-deployer]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@kvm-r04-31 contrail-ansible-deployer]# uname -r
3.10.0-862.14.4.el7.x86_64
[root@kvm-r04-31 contrail-ansible-deployer]#
[root@kvm-r04-31 contrail-ansible-deployer]# ansible --version
ansible 2.4.2.0
config file = /root/contrail-ansible-deployer/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 = /usr/bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
[root@kvm-r04-31 contrail-ansible-deployer]#

We had the same issue. Seems like Ansible script expects all hosts to be up and reachable. In case one of the hosts can't be reached script fails for every host.