aristanetworks / ansible-cvp

Ansible modules for Arista CloudVision
http://cvp.avd.sh
Apache License 2.0
66 stars 61 forks source link

Bug (arista.cvp.dhcp_configuration) Setting dhcp_packages_state=="absent" fails remaining tasks #639

Closed alexeygorbunov closed 7 months ago

alexeygorbunov commented 1 year ago

Issue Summary

Role arista.cvp.dhcp_configuration exposes variable dhcp_packages_state which is later used by task install packages inside online.yaml.

If customer sets dhcp_packages_state: "absent" -> this will effectively remove package {{ dhcp_packages }} from targeted CVP and will trigger a failure of the subsequent task check & activate DHCP service (which tries to unconditionally start service {{ dhcp_service }} which depends on removed package).

Which component(s) of AVD impacted

other

How do you run AVD ?

Ansible CLI (with virtual-env or native python)

Input variables

// playbook

- name: 'Enable DHCP server on ACTIVE CVP DHCP node '
  vars: 
    dhcp_packages_state: "absent"
  import_role:
    name: arista.cvp.dhcp_configuration
  when: inventory_hostname in groups['DHCP_SERVER']

// role's tasks related to package/service management (./ansible_collections/arista/cvp/roles/dhcp_configuration/tasks/online.yml)

- name: install packages
  become: true
  package:
    name: "{{ dhcp_packages }}"
    state: "{{ dhcp_packages_state }}"

- name: check & activate DHCP service
  become: true
  service:
    name: '{{ dhcp_service }}'
    enabled: true
    state: started

Steps to reproduce

1. Set variable "dhcp_packages_state" to "absent"
2. Trigger arista.cvp.dhcp_configuration in online mode
3. Task 'Enable DHCP server on ACTIVE CVP DHCP node' will fail

Relevant log output

TASK [arista.cvp.dhcp_configuration : Start creation/update process.] ********************************************************************************************************************************************************************************************************************************
skipping: [<hidden>]
included: /opt/AVD/ansible_collections/arista/cvp/roles/dhcp_configuration/tasks/./online.yml for <hidden>

TASK [arista.cvp.dhcp_configuration : gather os specific variables for Centos / Red Hat OS] **********************************************************************************************************************************************************************************************************
ok: [<hidden>]

TASK [arista.cvp.dhcp_configuration : gather os specific variables for Debian / Ubuntu OS] ***********************************************************************************************************************************************************************************************************
skipping: [<hidden>]

TASK [arista.cvp.dhcp_configuration : update packages list] ******************************************************************************************************************************************************************************************************************************************
skipping: [<hidden>]

TASK [arista.cvp.dhcp_configuration : install packages] **********************************************************************************************************************************************************************************************************************************************
changed: [<hidden>]

TASK [arista.cvp.dhcp_configuration : include_tasks] *************************************************************************************************************************************************************************************************************************************************
skipping: [<hidden>]

TASK [arista.cvp.dhcp_configuration : generate DHCPd configuration file] *****************************************************************************************************************************************************************************************************************************
changed: [<hidden>]

TASK [arista.cvp.dhcp_configuration : check & activate DHCP service] *********************************************************************************************************************************************************************************************************************************
fatal: [<hidden>]: FAILED! => {"changed": false, "msg": "Could not find the requested service dhcpd: host"}

PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************************************
<hidden>   : ok=3    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
<hidden>   : ok=6    changed=2    unreachable=0    failed=1    skipped=4    rescued=0    ignored=0   

(python3_9_2_venv) root@N<hidden>:<hidden>#

Code of Conduct

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days