Includes with limits and tags?

13 views
Skip to first unread message

Josh Smift

unread,
Mar 3, 2017, 11:06:22 AM3/3/17
to ansible...@googlegroups.com
We have a playbook that restores some data from a backup to a host, and
afterwards we want to run another playbook that fixes up some things in
the backup, but that other playbook is more general, and does a whole
bunch of tasks, and affects all the hosts of this type. We'd rather only
run the tasks that we know we need to run (which are identified by a tag),
and only run them on the host they need to run on. Something like

- include: hosttype.yml
limit: "{{ restorehost }}"
tags: mytags

That actual code doesn't actually work, obviously.

Is there a way to do this within Ansible?

(We can do it by hand, obviously, but the restore playbook takes a long
time, and someone has to then remember to come along and run hosttype.yml
one when the restore is done. We could create a two-line shell script that
run both playbooks, but it'd be cool to just be able to do this with an
include.)

-Josh (j...@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

Kai Stian Olstad

unread,
Mar 3, 2017, 11:22:10 AM3/3/17
to ansible...@googlegroups.com
On 03. mars 2017 17:06, Josh Smift wrote:
> We have a playbook that restores some data from a backup to a host, and
> afterwards we want to run another playbook that fixes up some things in
> the backup, but that other playbook is more general, and does a whole
> bunch of tasks, and affects all the hosts of this type. We'd rather only
> run the tasks that we know we need to run (which are identified by a tag),
> and only run them on the host they need to run on. Something like
>
> - include: hosttype.yml
> limit: "{{ restorehost }}"
> tags: mytags
>
> That actual code doesn't actually work, obviously.
>
> Is there a way to do this within Ansible?

You could do something like this if you are using ssh keys for login.
- command: ansible-playbook hosttype.yml -l {{ restorehost }} -t mytags

--
Kai Stian Olstad

Stankovic, Marko

unread,
Mar 3, 2017, 11:35:16 AM3/3/17
to ansible...@googlegroups.com
There's this feature request related to your question:
https://github.com/ansible/ansible/issues/14117

Cheers,
Marko
CONFIDENTIALITY NOTICE: This message is the property of International Game Technology PLC and/or its subsidiaries and may contain proprietary, confidential or trade secret information. This message is intended solely for the use of the addressee. If you are not the intended recipient and have received this message in error, please delete this message from your system. Any unauthorized reading, distribution, copying, or other use of this message or its attachments is strictly prohibited.
Reply all
Reply to author
Forward
0 new messages