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

[WIP] Add a 'ansible-role' cli #45861

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
4 participants
@alikins
Contributor

alikins commented Sep 19, 2018

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
  • Feature Pull Request
COMPONENT NAME

lib/ansible/cli/role.py

ANSIBLE VERSION
ansible 2.8.0.dev0 (ansible_role_ier 31618fb8ea) last updated 2018/09/19 14:26:36 (GMT -400)
  config file = /home/adrian/src/ansible/ansible.cfg
  configured module search path = ['/home/adrian/ansible/my-modules']
  ansible python module location = /home/adrian/src/ansible/lib/ansible
  executable location = /home/adrian/src/ansible/bin/ansible
  python version = 3.6.6 (default, Jul 19 2018, 16:29:00) [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
Add a 'ansible-role' cli
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
@ansibot

This comment has been minimized.

Contributor

ansibot commented Sep 19, 2018

@jamescassell

This comment has been minimized.

Contributor

jamescassell commented Sep 19, 2018

Awesome! Beats having to create a trivial playbook for each role, or a generic playbook like

---
- hosts: "{{ ansible_limit }}"
  roles:
  - "{{ role_name }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment