Compiling a Playbook or resolving variables

20 views
Skip to first unread message

Matt Ford

unread,
Apr 13, 2015, 8:12:21 AM4/13/15
to ansible...@googlegroups.com
Hi,

I would like to be able to sort-of compile a playbook.  Ideally I'd like to be able to see my playbook with all variables fully resolved (useful for some tools we are using to reason about Ansible).

For example; something like this would replace all {{ }} code with the real variables.
```
- hosts: localhost
  connection: local
  gather_facts: false

  vars_files:
    - "../vars/all.yml"
    - "../vars/{{ env }}.yml"

  tasks:
    - name: create rabbitmq-internal stack
      cloudformation:
        stack_name: "{{ rabbitmq_internal_stack }}"
        state: "present"
        disable_rollback: true
        region: "{{ cfn_aws_region }}"
        template: "../templates/rabbitmq-internal.json"
        template_parameters:
          name:         "rabbitmq-internal"
          public:       "false"
          environment:  "{{ env }}"
```

We have a simplar shell based parser but this is a dirty hack ( and fails on more complex j2 pipes).  What would be the best approach to have Ansible do it?  It must do the variable resolution so I figure we can back on to that.  I've not looked at the code yet but figured some one might have done it all ready or perhaps a guru can point me to an elegant hack?

Many thanks for any pointers,

Matt.

Brian Coca

unread,
Apr 13, 2015, 9:12:12 AM4/13/15
to ansible...@googlegroups.com
it is not that easy, the variables get resolved at different stages
and might have different values depending on that, so even if you run
through jinja2 with the loaded variables, you might not get the same
results as when the play actually runs.


--
Brian Coca
Reply all
Reply to author
Forward
0 new messages