Any way to gather localhost information to use in templates for remote hosts?

27 views
Skip to first unread message

Brian Huddleston

unread,
Apr 19, 2016, 7:06:04 PM4/19/16
to Ansible Project
I'm trying to write a task that updates the MODT (Message of the Day) for the target host the playbook is touching.

I'm trying to capture localhost information <name of the playbook> and the <login name of the user running the playbook> and add those to the MOTD for each target host the playbook touches, here is an example:

### ----------------------------------------------------------------
### THIS BOX IS BEING MANAGED BY ANSIBLE:
### ----------------------------------------------------------------
### Last updated  : Saturday, Apr. 16, 2016
### Last playbook : testbox.yml
### Last run by   : johndoe
###------------------------------------------------------------------

All of the variables and facts I find reference the target machine, not the machine running the commands.

Brian Huddleston

unread,
Apr 19, 2016, 11:01:43 PM4/19/16
to Ansible Project
I think I've figured out (2) of them:

### Last updated  : {{ ansible_date_time.iso8601 }}{{ ansible_date_time.tz }}"
### Last run by   : {{ lookup('env','USER') }}"

But I have no idea how to lookup the Playbook that is calling the roles and such:

### Playbook : testbox.yml"

Any pointers?
Reply all
Reply to author
Forward
0 new messages