nuagenetworks / nuage-metroae

Nuage Networks Metro Automation Engine
http://devops.nuagenetworks.net
Apache License 2.0
44 stars 17 forks source link

VSD hostname ping brake vsd-predeply role for ansible 2.2.1.0 #424

Closed agorbachev closed 6 years ago

agorbachev commented 6 years ago

New version of vsd-predeploy role does not work with ansible v 2.2.1.0

Now there is ping check if IP is free or not

---
- name: Ping VSD hostname
  command: ping -c 1 {{ hostname }}
  ignore_errors: yes
  register: ping_result
  delegate_to: localhost

- name: Assert no response to ping of VSD hostname
  assert:
    that: "ping_result.rc != 0"
    msg:  "Someone responded to ping of VSD hostname. Quitting."

but registered variable ping_result does not have rc key and playbook failed

some outputs:

[root@metro-host nuage-metro]# ansible --version
ansible 2.2.1.0
  config file = /opt/nuage-metro/ansible.cfg
  configured module search path = ['./library/']
[root@metro-host nuage-metro]# ./metro-ansible playbooks/vsd_predeploy.yml
+ PLAYBOOK=playbooks/vsd_predeploy.yml
+ shift
+ [[ -a playbooks/vsd_predeploy.yml ]]
+ echo 'Executing playbooks/vsd_predeploy.yml'
Executing playbooks/vsd_predeploy.yml
++ which ansible-playbook
+ /bin/ansible-playbook -i hosts playbooks/vsd_predeploy.yml

PLAY [vsds] ********************************************************************

TASK [vsd-predeploy : Ping VSD hostname] ***************************************
fatal: [vsd-test.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'hostname' is undefined\n\nThe error appears to have been in '/opt/nuage-metro/roles/vsd-predeploy/tasks/main.yml': line 2, column3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Ping VSD hostname\n  ^ here\n"}
...ignoring

TASK [vsd-predeploy : debug] ***************************************************
ok: [vsd-test.pod30.eu.nuagedemo.net] => {
    "ping_result": {
        "failed": true,
        "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'hostname' is undefined\n\nThe error appears to have been in '/opt/nuage-metro/roles/vsd-predeploy/tasks/main.yml': line 2, 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: Ping VSD hostname\n  ^ here\n"
    }
}

TASK [vsd-predeploy : Assert no response to ping of VSD hostname] **************
fatal: [vsd-test.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The conditional check 'ping_result.rc != 0' failed. The error was: error while evaluating conditional (ping_result.rc != 0): 'dict object' has no attribute 'rc'"}

PLAY RECAP *********************************************************************
vsd-test.pod30.eu.nuagedemo.net : ok=2    changed=0    unreachable=0    failed=1
agorbachev commented 6 years ago

btw the same issue with ansible 2.4

(metro-ansible24) [root@metro-host nuage-metro]# ansible --version
ansible 2.4.1.0
  config file = /opt/nuage-metro/ansible.cfg
  configured module search path = [u'/opt/nuage-metro/library']

failed with

(metro-ansible24) [root@metro-host nuage-metro]# ./metro-ansible install_vsd.yml
+ PLAYBOOK=install_vsd.yml
+ shift
+ [[ -a install_vsd.yml ]]
+ echo 'Executing install_vsd.yml'
Executing install_vsd.yml
++ which ansible-playbook
+ /opt/metro-ansible24/bin/ansible-playbook -i hosts install_vsd.yml
[DEPRECATION WARNING]: DEFAULT_TASK_INCLUDES_STATIC option, include itself is deprecated and this setting will not matter in the future . This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: 'include' for playbook includes. You should use 'import_playbook' instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: The use of 'include' for tasks has been deprecated. Use 'import_tasks' for static inclusions or 'include_tasks' for dynamic inclusions. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: include is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [vsds] ****************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [vsd-predeploy : Ping VSD hostname] ***********************************************************************************************************************************************************************************************************************************************************************************
fatal: [vsd-test.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The task includes an option with an undefined variable. The error was: 'hostname' is undefined\n\nThe error appears to have been in '/opt/nuage-metro/roles/vsd-predeploy/tasks/main.yml': line 2, 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: Ping VSD hostname\n  ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'hostname' is undefined"}
...ignoring
fatal: [vsd-test2.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The task includes an option with an undefined variable. The error was: 'hostname' is undefined\n\nThe error appears to have been in '/opt/nuage-metro/roles/vsd-predeploy/tasks/main.yml': line 2, 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: Ping VSD hostname\n  ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'hostname' is undefined"}
...ignoring

TASK [vsd-predeploy : Assert no response to ping of VSD hostname] **********************************************************************************************************************************************************************************************************************************************************
fatal: [vsd-test.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The conditional check 'ping_result.rc != 0' failed. The error was: error while evaluating conditional (ping_result.rc != 0): 'dict object' has no attribute 'rc'"}
fatal: [vsd-test2.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The conditional check 'ping_result.rc != 0' failed. The error was: error while evaluating conditional (ping_result.rc != 0): 'dict object' has no attribute 'rc'"}

PLAY RECAP *****************************************************************************************************************************************************************************************************************************************************************************************************************
vsd-test.pod30.eu.nuagedemo.net : ok=1    changed=0    unreachable=0    failed=1
vsd-test2.pod30.eu.nuagedemo.net : ok=1    changed=0    unreachable=0    failed=1
jonasvermeulen commented 6 years ago

Hi Alexey,

hostname should be defined in host_vars/vsd-test.pod30.nuagedemo.net (your example) If it is not, then it is more a build.yml / build-upgrade.yml issue.

Jonas

On Thu, Oct 26, 2017 at 8:30 AM, Aleksey Gorbachev <notifications@github.com

wrote:

btw the same issue with ansible 2.4

(metro-ansible24) [root@metro-host nuage-metro]# ansible --version ansible 2.4.1.0 config file = /opt/nuage-metro/ansible.cfg configured module search path = [u'/opt/nuage-metro/library']

failed with

(metro-ansible24) [root@metro-host nuage-metro]# ./metro-ansible install_vsd.yml

  • PLAYBOOK=install_vsd.yml
  • shift
  • [[ -a install_vsd.yml ]]
  • echo 'Executing install_vsd.yml' Executing install_vsd.yml ++ which ansible-playbook
  • /opt/metro-ansible24/bin/ansible-playbook -i hosts install_vsd.yml [DEPRECATION WARNING]: DEFAULT_TASK_INCLUDES_STATIC option, include itself is deprecated and this setting will not matter in the future . This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. [DEPRECATION WARNING]: 'include' for playbook includes. You should use 'import_playbook' instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. [DEPRECATION WARNING]: The use of 'include' for tasks has been deprecated. Use 'import_tasks' for static inclusions or 'include_tasks' for dynamic inclusions. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. [DEPRECATION WARNING]: include is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [vsds] ****

TASK [vsd-predeploy : Ping VSD hostname] *** fatal: [vsd-test.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The task includes an option with an undefined variable. The error was: 'hostname' is undefined\n\nThe error appears to have been in '/opt/nuage-metro/roles/vsd-predeploy/tasks/main.yml': line 2, 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: Ping VSD hostname\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'hostname' is undefined"} ...ignoring fatal: [vsd-test2.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The task includes an option with an undefined variable. The error was: 'hostname' is undefined\n\nThe error appears to have been in '/opt/nuage-metro/roles/vsd-predeploy/tasks/main.yml': line 2, 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: Ping VSD hostname\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'hostname' is undefined"} ...ignoring

TASK [vsd-predeploy : Assert no response to ping of VSD hostname] ** fatal: [vsd-test.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The conditional check 'ping_result.rc != 0' failed. The error was: error while evaluating conditional (ping_result.rc != 0): 'dict object' has no attribute 'rc'"} fatal: [vsd-test2.pod30.eu.nuagedemo.net]: FAILED! => {"failed": true, "msg": "The conditional check 'ping_result.rc != 0' failed. The error was: error while evaluating conditional (ping_result.rc != 0): 'dict object' has no attribute 'rc'"}

PLAY RECAP *****vsd-test.pod30.eu.nuagedemo.net : ok=1 changed=0 unreachable=0 failed=1vsd-test2.pod30.eu.nuagedemo.net : ok=1 changed=0 unreachable=0 failed=1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nuagenetworks/nuage-metro/issues/424#issuecomment-339565032, or mute the thread https://github.com/notifications/unsubscribe-auth/ALxVGhK6dwBoE9GwtskT63FMxSolfS4aks5swCb5gaJpZM4QFofc .

ghost commented 6 years ago

Can you share your build_vars.yml file?

agorbachev commented 6 years ago

@bacastelli

[root@metro-host nuage-metro]# cat build_vars.yml
---
###
# See BUILD.md for details
###
# Paths
# Paths to find zipped (tar.gz) files and unzipped files (e.g. qcow2)
# Both are required to run the nuage_unzip role. nuage_unzipped_files_dir
# is required when one or more operation lists, below, are set to 'install'
# or 'upgrade'.
nuage_zipped_files_dir: "/opt/nuage-distrib"
nuage_unzipped_files_dir: "/opt/nuage-distrib/unzip"

###
# Path to a public key file to be injected in to VSD,VNS Util, VCIN and VSTAT
# vms during deployment and corresponding private file to be used to connect to
# the components during deployment
user_ssh_pub_key: ~/.ssh/id_rsa.pub
user_ssh_priv_key: ~/.ssh/id_rsa

###
# Usernames
# remote_user names for ansible to execute as on the target server (hypervisor)
# and Ansible host. target_server_username is the remote_user for all
# hypervisors.
# ansible_sudo_username is the sudo user for local actions.
target_server_username: root
ansible_sudo_username: root

###
# The IP addr or hostname of the Ansible host
ansible_deployment_host: 10.163.30.3

###
# Openstack credentials
os_auth:
  username: admin
  password: Alcateldc
  project_name: admin
  auth_url: http://10.167.30.20:5000/v2.0

###
# Location for health reports

metro_reports_dir: "{{ playbook_dir }}/reports"

###
# NTP configuration
# Note: Must be in dotted-decimal format
ntp_server_list:
  - 10.167.30.4
  - 10.168.27.51

# DNS configuration
dns_server_list:
  - 10.167.30.10

dns_domain: pod30.eu.nuagedemo.net

###
# Misc. param
timezone: Europe/Brussels
yum_proxy: "NONE"
yum_update: yes
yum_pin: yes

###
# VSD params
# vsd_sa_or_ha = ha for cluster, sa for standalone deployment
vsd_sa_or_ha: sa

###
# VSD FQDN
# Use xmpp fqdn for clustered VSDs and the vsd fqdn for stand alone
# This variable must be populated for all the components except VRS deployment
vsd_fqdn_global: "vsd1.{{ dns_domain }}"

vsd_operations_list:
  - install

myvsds:
  - { hostname: "vsd-test.{{ dns_domain }}",
      vmname: vsd-test,
      target_server_type: heat,
      dhcp: False,
      mgmt_ip: 10.163.30.4,
      vsd_image: nuage-vsd-5.1.1_22,
      vsd_flavor: nuage-vsd,
      vsd_network: PUBLIC-PROVIDER-VLAN45,
      vsd_subnet: PUBLIC-SUBNET }
  - { hostname: "vsd-test2.{{ dns_domain }}",
      vmname: vsd-test2,
      target_server_type: heat,
      dhcp: False,
      mgmt_ip: 10.163.30.5,
      vsd_image: nuage-vsd-5.1.1_22,
      vsd_flavor: nuage-vsd,
      vsd_network: PUBLIC-PROVIDER-VLAN45,
      vsd_subnet: PUBLIC-SUBNET }

vsc_operations_list:
  - install

myvscs:
  - { hostname: "vsc-test1.{{ dns_domain }}",
      target_server_type: heat,
      dhcp: False,
      mgmt_ip: 10.163.30.6,
      ctrl_ip: 10.161.30.6,
      vsc_image: nuage-vsc-5.1-1-23_v2,
      vsc_flavor: nuage-vsc,
      vsc_mgmt_network: PUBLIC-PROVIDER-VLAN45,
      vsc_mgmt_subnet: PUBLIC-SUBNET,
      vsc_control_network: UNDERLAY1-PROVIDER-VLAN10,
      vsc_control_subnet: UNDERLAY1-SUBNET,
      vsd_fqdn: "vsd-test.{{ dns_domain }}",
      xmpp_username: "vsc-test1.{{ dns_domain }}" }

@jonasvermeulen hostname is not defined

[root@metro-host nuage-metro]# cat host_vars/vsd-test.pod30.eu.nuagedemo.net
# *** WARNING ***
# This is a generated file. Manual changes to this file
# will be lost if reset-build or build is run
#
target_server_type: heat

vsd_sa_or_ha: sa

dhcp: False
mgmt_ip: 10.163.30.4
vsd_image: nuage-vsd-5.1.1_22
vsd_flavor: nuage-vsd
vsd_network: PUBLIC-PROVIDER-VLAN45
vsd_subnet: PUBLIC-SUBNET
ghost commented 6 years ago

The logic in roles/build/templates/vsd.j2 only sets hostname if target_server_type id kvm or vcenter. We will fix it right away.

ghost commented 6 years ago

I fixed it. The problem wasn't limited to vsd. Several other components needed the definition logic fixed.