Hi Rob,
Like James said, something like this should work:
ansible-playbook my_playbook.yml -i local -e '{ "roles_to_deploy" :
['role1','role2']}'
An alternative approach using tags:
variables file: host_vars/ubuntu-trusty64-01
~~~
---
roles:
- collectd
- nginx
~~~
playbook file: setup.yml
~~~
roles:
- { role: collectd, when: "'collectd' in roles and roles is defined",
tags: [ 'collectd' ] }
- { role: nginx, when: "'nginx' in roles and roles is defined", tags: [
'nginx' ] }
- { role: mariadb, when: "'mariadb' in roles and roles is defined",
tags: [ 'mariadb' ] }
~~~
# to install roles collectd and nginx
~~~
ansible-playbook setup.yml --limit ubuntu-trusty64-01
~~~
# to install only role collectd
~~~
ansible-playbook setup.yml --limit ubuntu-trusty64-01 -t collectd
~~~
Keeping the list of roles allowed to be installed on a server in a variable
enforces desired state.
Regards,
Osvaldo
El viernes, 27 de marzo de 2015, 9:48:28 (UTC-3), James Cammarata escribió:
>
> Hi Rob, this is possible, you just need to format the extra variables as
> JSON, as documented here:
> http://docs.ansible.com/playbooks_variables.html#passing-variables-on-the-command-line
>
> James Cammarata
> Director, Ansible Core Engineering
> github: jimi-c
>
> On Thu, Mar 26, 2015 at 8:37 PM, Rob White <[email protected]
> <javascript:>> wrote:
>
>> Is it possible to pass a list as an extra-vars variable on the command
>> line?
>>
>> I have tried various syntax but it doesn't work.
>>
>> E.g.
>>
>> ansible-playbook my_playbook.yml -i local --extra-vars
>> roles_to_deploy=role1,role2
>> ansible-playbook my_playbook.yml -i local --extra-vars
>> roles_to_deploy=[role1,role2]
>> ansible-playbook my_playbook.yml -i local --extra-vars
>> roles_to_deploy=['role1','role2']
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/a1c3c3ee-f51e-42c1-99bf-677ef6eaa8e5%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/a1c3c3ee-f51e-42c1-99bf-677ef6eaa8e5%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ebc86c9a-8a68-4d3b-9efc-d7b976050f97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.