/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Administration/Server/Provisioning/ansible/templates.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2017-04-03 02:45:17 UTC
  • Revision ID: csa@suren.me-20170403024517-dwzj0z0k1cmhxm7u
Restructuring, OpenShift, Ansible, Git

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Templates (Jinja2)
 
2
=========
 
3
 - Substituting variables or expressions '{{ <expression> }}'
 
4
        "{{ variable }}"
 
5
 Type mangling:
 
6
         "{{ (variable1 | int) + (variable2 | int) }}"
 
7
 Also can be part of the longer strings:
 
8
         "/dev/sda{{ (variable1 | int) + (variable2 | int) }}"
 
9
 
 
10
 - Accessing various variables
 
11
    {{ lookup('env','HOME') }}                                          - shell environment
 
12
    {{ hostvars[groups['webservers'][0]] }}                             - hosts in the groups defined in inventory (this will reference to the root of all gathered facts)
 
13
 
 
14
 - Dynamic variables
 
15
    {{ ansible_lvm['lvs'][<var_holding_lv>]['vg'] }}
 
16
 
 
17
 - A complete J2 templates files can be substantiated and installed in specified locations using the 'template' module
 
18
    template: src="path/to/template.j2" dst="/path/destination/file" owner="root" group="root' mode="0755"