Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent behaviour and documentation of the os10_config plugin #114

Open
zerwes opened this issue Feb 7, 2022 · 0 comments
Open

inconsistent behaviour and documentation of the os10_config plugin #114

zerwes opened this issue Feb 7, 2022 · 0 comments

Comments

@zerwes
Copy link

zerwes commented Feb 7, 2022

SUMMARY

As discovered in #113, the plugin os10_config shows a inconsistent behavior if called with the full name dellemc.os10.os10_config or if the collection is imported first via the collection keyword at a play level and referenced later via the short plugin name os10_config.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

os10_config

ANSIBLE VERSION
ansible [core 2.12.2]
  config file = None
  configured module search path = ['/home/zerwes/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /home/zerwes/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 2.11.3
  libyaml = True

COLLECTION VERSION
Collection   Version
------------ -------
dellemc.os10 1.1.1  

But even the current version directly from github seems to be affected.

CONFIGURATION

Occurs even in a clean env

$ ansible-config dump --only-changed 
$ 
OS / ENVIRONMENT

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

STEPS TO REPRODUCE
OK
$ ansible-playbook -i hosts dellos10_fetch_config.yml

PLAY [Configuration Retrieval Teseting] ***************************************************************************************************************************************************************************

TASK [ensure old backup file is deleted] **************************************************************************************************************************************************************************
changed: [swa31ber0.ber0.rosalux.org]

TASK [Retrieve Configuration] *************************************************************************************************************************************************************************************
changed: [swa31ber0.ber0.rosalux.org]

TASK [check if the backup file exists] ****************************************************************************************************************************************************************************
ok: [swa31ber0.ber0.rosalux.org]

TASK [assert the backup file exists] ******************************************************************************************************************************************************************************
ok: [swa31ber0.ber0.rosalux.org] => {
    "changed": false,
    "msg": "yeah! /tmp/bkups/junk.txt is there!"
}

PLAY RECAP ********************************************************************************************************************************************************************************************************
swa31ber0.ber0.rosalux.org : ok=4    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

using playbook $ cat dellos10_fetch_config.yml

---
- name: Configuration Retrieval Teseting
  connection: ansible.netcommon.network_cli
  gather_facts: false
  hosts: all
  collections:
    - dellemc.os10
  vars:
    ansible_command_timeout: 120
    dir_path: /tmp/bkups
    filename: junk.txt
    fp2b_filename: "{{ [dir_path, filename,] | path_join }}"
  tasks:
    - name: ensure old backup file is deleted
      file:
        path: "{{ fp2b_filename }}"
        state: absent
    - name: Retrieve Configuration
      os10_config:
        backup: true
        backup_options:
          dir_path: "{{ dir_path }}"
          filename: "{{ filename }}"
        lines:
          - ip host junk1 1.1.1.1
          - no ip host junk1
        save: yes
    - name: check if the backup file exists
      stat:
        path: "{{ fp2b_filename }}"
      register: _statr
    - name: assert the backup file exists
      assert:
        that: _statr.stat.exists
        fail_msg: "gosh darn it! {{ fp2b_filename }} not found!"
        success_msg: "yeah! {{ fp2b_filename }} is there!"
...
ERROR
$ ansible-playbook -i hosts dellos10_fetch_config2.yml

PLAY [Configuration Retrieval Teseting] ***************************************************************************************************************************************************************************

TASK [ensure old backup file is deleted] **************************************************************************************************************************************************************************
changed: [swa31ber0.ber0.rosalux.org]

TASK [Retrieve Configuration] *************************************************************************************************************************************************************************************
changed: [swa31ber0.ber0.rosalux.org]

TASK [check if the backup file exists] ****************************************************************************************************************************************************************************
ok: [swa31ber0.ber0.rosalux.org]

TASK [assert the backup file exists] ******************************************************************************************************************************************************************************
fatal: [swa31ber0.ber0.rosalux.org]: FAILED! => {
    "assertion": "_statr.stat.exists",
    "changed": false,
    "evaluated_to": false,
    "msg": "gosh darn it! /tmp/bkups/junk.txt not found!"
}

PLAY RECAP ********************************************************************************************************************************************************************************************************
swa31ber0.ber0.rosalux.org : ok=3    changed=2    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

using playbook $ cat dellos10_fetch_config2.yml

---
- name: Configuration Retrieval Teseting
  connection: ansible.netcommon.network_cli
  gather_facts: false
  hosts: all
  vars:
    ansible_command_timeout: 120
    dir_path: /tmp/bkups
    filename: junk.txt
    fp2b_filename: "{{ [dir_path, filename,] | path_join }}"
  tasks:
    - name: ensure old backup file is deleted
      file:
        path: "{{ fp2b_filename }}"
        state: absent
    - name: Retrieve Configuration
      dellemc.os10.os10_config:
        backup: true
        backup_options:
          dir_path: "{{ dir_path }}"
          filename: "{{ filename }}"
        lines:
          - ip host junk1 1.1.1.1
          - no ip host junk1
        save: yes
    - name: check if the backup file exists
      stat:
        path: "{{ fp2b_filename }}"
      register: _statr
    - name: assert the backup file exists
      assert:
        that: _statr.stat.exists
        fail_msg: "gosh darn it! {{ fp2b_filename }} not found!"
        success_msg: "yeah! {{ fp2b_filename }} is there!"
...

diff of the playbooks:
$ diff -Naur dellos10_fetch_config.yml dellos10_fetch_config2.yml

--- dellos10_fetch_config.yml	2022-02-07 08:28:20.131843707 +0100
+++ dellos10_fetch_config2.yml	2022-02-07 08:35:12.697903297 +0100
@@ -3,8 +3,6 @@
   connection: ansible.netcommon.network_cli
   gather_facts: false
   hosts: all
-  collections:
-    - dellemc.os10
   vars:
     ansible_command_timeout: 120
     dir_path: /tmp/bkups
@@ -16,7 +14,7 @@
         path: "{{ fp2b_filename }}"
         state: absent
     - name: Retrieve Configuration
-      os10_config:
+      dellemc.os10.os10_config:
         backup: true
         backup_options:
           dir_path: "{{ dir_path }}"
EXPECTED RESULTS

The behavior should be the same as stated in https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#using-collections-in-a-playbook
The documentation of https://github.com/Rosa-Luxemburgstiftung-Berlin/dellemc.os10/blob/master/docs/dellemc.os10.os10_config_module.rst#L26 should be fixed as long as the different behavior is not fixed.

ACTUAL RESULTS

confusing documentation and inconsistent behavior resulting in #113, #102 and ansible-collections/dellemc.os6#45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant