Giter Club home page Giter Club logo

Comments (12)

ansibot avatar ansibot commented on September 26, 2024

Files identified in the description:

None

If these files are incorrect, please update the component name section of the description or use the component bot command.

from ansible.

bcoca avatar bcoca commented on September 26, 2024

you have extra vars already to cover that scope

from ansible.

glennpratt avatar glennpratt commented on September 26, 2024

I thought I mentioned extra vars or perhaps I don't understand. I'm looking at this from the perspective of a collection author.

IIUC extra vars:

  • Can't have a common default from a collection author
  • Can't be dynamic unless the user invoking ansible calls a script

from ansible.

s-hertel avatar s-hertel commented on September 26, 2024

Extra vars can have a common default, either provided in the extra vars or in the playbook (just need to use the Jinja2 default filter).

They also can be dynamic, for example, the extra vars could use lookup plugins.

from ansible.

mkrizek avatar mkrizek commented on September 26, 2024

Closing as per above.

If you have further questions please stop by IRC or the mailing list:

See this page for a complete and up to date list of communication channels and their purposes:

from ansible.

glennpratt avatar glennpratt commented on September 26, 2024

Extra vars can have a common default, either provided in the extra vars or in the playbook (just need to use the Jinja2 default filter).

They also can be dynamic, for example, the extra vars could use lookup plugins.

extra vars are not provided by a collection author.

jinja2 default means repeating yourself frequently and not having a reasonable point to document vars

from ansible.

glennpratt avatar glennpratt commented on September 26, 2024

They also can be dynamic, for example, the extra vars could use lookup plugins.

Yes, I can write custom lookup plugins - that's what I'm doing for now.

from ansible.

s-hertel avatar s-hertel commented on September 26, 2024

It will probably be easier for playbooks to take variables once they can document it https://github.com/ansible/ansible/projects/48#card-90150512, but there isn't anything stopping a collection from using vars for these fields or providing a file to override the defaults optionally.

It could depend on the playbook/author. Sometimes strategy is hardcoded because the play isn't compatible with all options, and so overrides the strategy config value. It might not occur to me to use a variable with default for hosts, because hardcoding a group name doesn't prevent configuration via inventory/--limit.

If you just want to use playbooks/vars/global.yml as an extra vars file, no lookup is needed:

ansible-playbook ns.col.playbook -e @/path/to/playbooks/vars/global.yml

from ansible.

glennpratt avatar glennpratt commented on September 26, 2024

That's mostly from the perspective of a user, not a collection author.

There are things I can't offer in a role that I can do with a playbook, but the user experience will be worse than it was with the role.

from ansible.

bcoca avatar bcoca commented on September 26, 2024

like role vars? I'm not sure your use case is not covered, specially because you are very vague about it. There are many ways to supply variables already and you have not shown an example of something that would require a new method.

from ansible.

glennpratt avatar glennpratt commented on September 26, 2024

An example of what I'm working on is improving / replacing this hack to do graceful, rolling Kubernetes cluster node restarts:
lablabs/ansible-role-rke2/blob/main/tasks/main.yml#L70-L77. I'm not the original author, I believe this hack pattern came from an issue in here.

The include_tasks hack is very limited, a performance concern and spams the logs. There are also multiple scenarios for this (config change, software change, kernel change + reboot).

In a large cluster, different serial patterns with a sane default (based on an arbitrary, configurable set of groups) would be ideal. For now, I'm using a lookup plugin for this - this could be optionally configured with extra vars, I just didn't find it as familiar and self-documenting as a vars / defaults file.

from ansible.

bcoca avatar bcoca commented on September 26, 2024

i'm not sure i understand the task, but it seems extremely contrived:

- name: Rolling restart when config files change
  ansible.builtin.include_tasks: change_config.yml
  with_items: "{{ groups[rke2_cluster_group_name] }}"
  loop_control:
    loop_var: _host_item
  when:
    - hostvars[_host_item].inventory_hostname == inventory_hostname
    - rke2_restart_needed

Can just be rewritten as:

- name: Rolling restart when config files change
  ansible.builtin.include_tasks: change_config.yml
  when:
   - rke2_cluster_group_name in group_names
   - rke2_restart_needed
  vars:
     _host_item: '{{inventory_hostname}}'

I still don't see the issue with needing external/extra vars nor how 'serial' comes into play or anything else you mention as a reason for the new feature you espouse.

In any case I would suggest that you pose your specific problems in the forums/mailing lists/irc and then return here when there are no solutions to it using existing systems. This is not a good place to go back and forth on these kind of issues.

from ansible.

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.