Joe Rosato on 1 Jun 2016 05:55:27 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Question for the ansible folk


Yes.. I thought it was this.. figured I'd ask in case someone had something up their sleeve!

Joe

On Wed, May 25, 2016 at 11:46 AM brent saner <brent.saner@gmail.com> wrote:

this is the proper way to perform actions directly on the host running the playbook. you CAN e.g.:

local_action: shell /bin/this_command

and remove the shell: and delegate_to: lines, but I prefer to use delegate_to for ease of readability and standardization across other remote tasks.

and yes, the output is ugly as hell and is fairly nonsensical.

On May 25, 2016 11:40, "Joe Rosato" <rosatoj@gmail.com> wrote:
Is there a cleaner way to do this? 

This works but makes it look like the playbook is doing something on host1 when it is not. This is part of a larger yaml that runs across a lot of nodes and at the end of the run I want to run a couple of commands on the local host.

Given /etc/ansible/hosts:
host1
host2
host3
host4


I run a playbook with:

 hosts: all
 become: yes
 remote_user: joe
 gather_facts: smart

 (lotta other stuff skipped here)

- name: Run this only on the local host
  run_once: yes
  delegate_to: localhost
  become: no
  shell: /bin/this_command



Output of ansible-playbook:


TASK [Run this only on the local host] *****************************************************
changed: [host1 -> localhost]


PLAY RECAP *********************************************************************
host1 : ok=1 changed=1 unreachable=0 failed=0
     

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
--
Joe
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug