Coder Social home page Coder Social logo

Comments (3)

Alphix avatar Alphix commented on June 13, 2024

No state is usually interpreted as "present" in DebOps roles, and the above logic doesn't really reflect that. But as far as I can remember, debops.debops.parse_kv_items should set an undefined state to present. @BerkhanBerkdemir: what did your inventory look like when you triggered this behaviour?

Anyway, I guess the logic above could be improved. A first thought would be to replace selectattr("state", "eq", "present") by rejectattr("state", "in", "[init, absent, ignore]")...buuut that doesn't work because rejectattr blows up when state is undefined.

I think a better option might be to replace this:

ansible.builtin.set_fact: 
  bind__tmp_top_views: '{{ bind__combined_zones 
                           | debops.debops.parse_kv_items(name="view") 
                           | selectattr("state", "eq", "present") }}'
...
ansible.builtin.set_fact: 
  bind__tmp_top_zones: '{{ bind__combined_zones 
                           | debops.debops.parse_kv_items(name="name") 
                           | selectattr("state", "eq", "present") }}'

With something like this:

ansible.builtin.set_fact: 
  bind__tmp_top_views: '{{ bind__tmp_top_views | d([]) + [ item ] }}'
loop: '{{ bind__combined_zones 
          | debops.debops.parse_kv_items(name="view") }}'
loop_control:
  label: '{{ item.view }}'
when: item.state | d("present") == "present"
...
ansible.builtin.set_fact: 
  bind__tmp_top_zones: '{{ bind__tmp_top_zones | d([]) + [ item ] }}'
loop: '{{ bind__combined_zones 
          | debops.debops.parse_kv_items(name="name") }}'
loop_control:
  label: '{{ item.name }}'
when: item.state | d("present") == "present"

from debops.

BerkhanBerkdemir avatar BerkhanBerkdemir commented on June 13, 2024

What did your inventory look like when you triggered this behavior?

I have used the suggested inventory which is in the documentation. Currently there is nothing in the production system but I'm testing everything in a virtual environment before I make this DebOps role available to my network.

I liked your approach @Alphix, and I would like to try that in my own development environment.

from debops.

BerkhanBerkdemir avatar BerkhanBerkdemir commented on June 13, 2024

I am actually thinking different in this bug at this point. Since both variables are already filled with data, we should be checking only if it is NOT. So, why are we checking if it is == 0? Let's check if it's > 0.

from debops.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.