[WIP] Add a 'ansible-role' cli #45861
Open
+255
−3
Conversation
Apply a role to a host list, similar to 'ansible localhost -m ping' And also use the ansible-role '-a' key=value args Let ansible-role -A specify which arg spec def to use. And fixup ansible-role to work with the current params for validate_arg_spec. The meta/arg_specs.yml will have a dict. Each key in the dict is the name of an arg spec, and the value is the arg spec definition. By default, the 'default' arg spec will be used unless otherwise specified. Only ways to specify the arg spec name at the moment are: - the ansible-role -A/--arg-spec-name cli options - change DEFAULT_ARG_SPEC_NAME in config For example using the test1 role in test/integration/targets/validate_arg_spec $ cd test/integration/targets/validate_arg_spec # will use the 'default' role arg specs from meta/arg_specs.yml $ ansible-role localhost -r test1 # will use the 'simple_preset' role arg spec from meta/arg_specs.yml $ ansible-role localhost -r test1 -A simple_preset Stop creating a validation task in ansible-role Role loading does it generally now, so ansible-role doesnt need to special case it. Add ansible-role to a doc index to fix ansible-test
Awesome! Beats having to create a trivial playbook for each role, or a generic playbook like ---
- hosts: "{{ ansible_limit }}"
roles:
- "{{ role_name }}" |
@jborean93 @alikins is this CLI command still relevant now that we have ansible-galaxy w/ role and collection support? Can we close the PR if its no longer needed? |
@samccann actually, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
SUMMARY
Add a 'ansible-role' cli
This is split off from the #44983 role arg spec pr.
Apply a role to a host list, similar to 'ansible localhost -m ping'
For example using test1 role in test/integration/targets/validate_arg_spec
$ cd test/integration/targets/validate_arg_spec
will use the 'default' role arg specs from meta/arg_specs.yml
$ ansible-role localhost -r test1
ISSUE TYPE
COMPONENT NAME
lib/ansible/cli/role.py
ANSIBLE VERSION