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

Bug: Setting array fails on subsequent runs #7

Closed
mandoway opened this issue May 11, 2022 · 4 comments
Closed

Bug: Setting array fails on subsequent runs #7

mandoway opened this issue May 11, 2022 · 4 comments

Comments

@mandoway
Copy link

I'm trying to write an ansible script to set values in an array and it works on the first run, but fails to execute on subsequent runs.

Expected

Ansible executes the playbook multiple times. Changes are only on the first run, and subsequent runs will return "ok".

Actual

First run works perfectly.
Subsequent runs will result in the following error:

Traceback (most recent call last):  File "/home/markus/.ansible/tmp/ansible-tmp-1652287937.9485567-6563-112810049557521/AnsiballZ_elektra.py", line 107, in <module>
    _ansiballz_main()
  File "/home/markus/.ansible/tmp/ansible-tmp-1652287937.9485567-6563-112810049557521/AnsiballZ_elektra.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/markus/.ansible/tmp/ansible-tmp-1652287937.9485567-6563-112810049557521/AnsiballZ_elektra.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.elektra_initiative.libelektra.plugins.modules.elektra', init_globals=dict(_module_fqn='ansible_collections.elektra_initiative.libelektra.plugins.modules.elektra', _modlib_path=modlib_path),
  File "/usr/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
  File "/tmp/ansible_elektra_payload_ldycfdoa/ansible_elektra_payload.zip/ansible_collections/elektra_initiative/libelektra/plugins/modules/elektra.py", line 289, in <module>
  File "/tmp/ansible_elektra_payload_ldycfdoa/ansible_elektra_payload.zip/ansible_collections/elektra_initiative/libelektra/plugins/modules/elektra.py", line 274, in main
  File "/tmp/ansible_elektra_payload_ldycfdoa/ansible_elektra_payload.zip/ansible_collections/elektra_initiative/libelektra/plugins/modules/elektra.py", line 164, in elektraSet
TypeError: in method 'Key___ne__', argument 2 of type 'kdb::Key const &'

I used the following playbook:

---
- name: install starhotel and configure application
  hosts: localhost
  connection: local
  collections:
    - elektra_initiative.libelektra
  tasks:
    - name: install starhotel
      shell: ./setup.sh
      args:
        chdir: '../../milangs/h2'
        creates: /usr/bin/starhotel

    - name: mount specification
      shell: ./mountall.sh
      args:
        chdir: '../../milangs/h2'
        creates: /usr/share/elektra/specification/starhotel.spec.ni

    - name: configure starhotel with 6 rooms
      collections:
        - elektra_initiative.libelektra
      elektra:
        mountpoint: user:/sw/cm2022/starhotel/#0/current
        recommends: True
        keys:
          server:
            url: starhotel.com
            ip: 0.0.0.0
            port: 2525
          hotel:
            season:
              begin: 05/05
              end: 30/10
            currency: EUR
            room:
              meta:
                array: '#5'
              '#0':
                ip: 10.0.0.1
                view: windowless
                atmosphere: air
                price: 50.00
              '#1':
                ip: 10.0.0.2
                view: sea
                atmosphere: nitrogen
                price: 60.00
              '#2':
                ip: 10.0.0.3
                view: mountain
                atmosphere: iron
                price: 30.00
              '#3':
                ip: 10.0.0.4
                view: crater
                atmosphere: water
                price: 45.00
              '#4':
                ip: 10.0.0.5
                view: plains
                atmosphere: hydrogen
                price: 123.00
              '#5':
                ip: 10.0.0.6
                view: other
                atmosphere: hydrogen
                price: 76.45
@markus2330
Copy link
Collaborator

Thank you for reporting this problem! @lukashartl can you take a look at it?

@lukashartl
Copy link
Collaborator

Of course.

This sounds a lot like #2 . I think the latest version hasn't been uploaded to ansible-galaxy yet.
@markus2330 can you trigger an import on the ansible galaxy website?

We should probably automate this... in conjunction with #5 .

@kodebach
Copy link
Member

I published the new version 0.2.2 to Ansible Galaxy.

We should probably automate this...

Yes. The import isn't actually triggered from the website. Instead you need to increase the version number in galaxy.yml and then run:

ansible-galaxy collection build
ansible-galaxy collection publish elektra_initiative-libelektra-*.tar.gz --token=$ANSIBLE_TOKEN

It should be simple enough to add a Github Action or Jenkins Job that does this. The job should be manually triggered IMO.

@markus2330
Copy link
Collaborator

I didn't try the problem as described above but I regularly apply configs with arrays, so I think this can be closed.

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

4 participants