Joe Rosato on 25 May 2016 08:40:07 -0700


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

[PLUG] Question for the ansible folk


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