amazon web services - 'ansible_date_time' is undefined -


trying register ec2 instance in aws ansible's ec2_ami module, , using current date/time version (we'll end making lot of amis in future).

this have:

- name: create new ami   hosts: localhost   connection: local   gather_facts: false   vars:   tasks:     - include_vars: ami_vars.yml     - debug: var=ansible_date_time     - name: register ec2 instance ami       ec2_ami: aws_access_key={{ ec2_access_key }}                aws_secret_key={{ ec2_secret_key }}                instance_id={{ temp_instance.instance_ids[0] }}                region={{ region }}                wait=yes                name={{ ami_name }}       with_items: temp_instance       register: new_ami 

from ami_vars.yml:

ami_version: "{{ ansible_date_time.iso8601 }}" ami_name: ami_test_{{ ami_version }} 

when run full playbook, error message:

fatal: [localhost]: failed! => {"failed": true, "msg": "error! error! error! 'ansible_date_time' undefined"} 

however, when run debug command separately, separate playbook, works fine:

- name: test date-time lookup   hosts: localhost   connection: local   tasks:     - include_vars: ami_vars.yml     - debug: msg="ami version {{ ami_version }}"     - debug: msg="ami name {{ ami_name }}" 

result:

task [debug] ******************************************************************* ok: [localhost] => {     "msg": "ami version 2016-02-05t19:32:24z" }  task [debug] ******************************************************************* ok: [localhost] => {     "msg": "ami name ami_test_2016-02-05t19:32:24z" } 

any idea what's going on?

remove this:

  gather_facts: false 

ansible_date_time part of facts , not gathering it.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -