DING! That worked. Thank you so much!
On Friday, May 20, 2016 at 11:56:12 AM UTC-5, Brian Coca wrote:
>
> you are mixing notations
>
> {{ hostvars['server1']['timestamp']['stdout'] }}
>
>
> --
> Brian Coca
>
--
You received this message because you are subscribed to the Google Groups
When I do this:
{{ hostvars['server1']['timestamp.stdout'] }}
as in:
- name: "Backup {{ proddbname }} Database"
mysql_db: "state=dump name={{ proddbname }} target={{ homedir }}{{
proddbname }}{{ hostvars['server01']['timestamp.stdout'] }}.sql.gz"
It gives me the error
fatal:
So in order to access this var/register from server01, I could do something
like in playbook-01.yml:
---
- hosts: "{{ hostvars['server01']['proddbhost'] }}"
(When I do that I get "ERROR! 'hostvars' is undefined"
On Friday, May 20, 2016 at 8:30:48 AM UTC-5, Brian Coca wrote:
>
> vars don't
---
- hosts: server01
remote_user: jlouthan
vars:
proddbhost: proddb01
tasks:
- name: Get current timestamp
local_action: command bash -c 'date +%Y-%m-%d.%H%M'
register: timestamp
run_once: true
- name: Get current datestamp
indented var: that is a copy/paste mistake.
So those vars and register will not persist to any of the other include
playbooks?
On Friday, May 20, 2016 at 7:49:18 AM UTC-5, Brian Coca wrote:
>
> So vars seems to be incorrectly indented, also you should not need to add
> 'bash' to command
>
>
By all accounts that I can see, the following should work:
---
- hosts: server01
remote_user: jlouthan
vars:
proddbhost: proddb01
tasks:
- name: Get current timestamp
local_action: command bash -c 'date +%Y-%m-%d.%H%M'
register: timestamp
run_once: true
-
So pulling in synchronize between two remote servers works like a champ:
---
- hosts: web14
remote_user: jlouthan
tasks:
- name: Get current timestamp
local_action: command bash -c 'date +%Y-%m-%d.%H%M'
register: timestamp
run_once: true
- name: Get current
That's it! Thank you!
To avoid being "that guy", here is the working playbook:
---
- hosts: dbserver
remote_user: jlouthan
tasks:
- name: Get current timestamp
local_action: command bash -c 'date +%Y-%m-%d.%H%M'
# Consider switch this to a shell module with date command
M"
> register: now
> run_once: true
>
> (or something similar adapted to your local environment) before your
> dump task and then use {{ now }} in the next tasks to always get the
> same timestamp.
>
> Best,
> Felix
>
>
>
> On Thu, 21 Apr 2016 08: