Difference between revisions of "Ansible Playbooks"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
+ | Set host connection to winrm on windows without ssh | ||
+ | |||
+ | And change auth creds via include vars by group name var | ||
+ | |||
+ | You could use template env vars with jinja template too | ||
+ | |||
https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html | https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html | ||
Line 11: | Line 17: | ||
ansible-playbook site.yml --limit datacenter2 -f 10 | ansible-playbook site.yml --limit datacenter2 -f 10 | ||
``` | ``` | ||
− | |||
Using if or lookup from env in jinja vars | Using if or lookup from env in jinja vars |
Revision as of 10:38, 18 November 2021
Set host connection to winrm on windows without ssh
And change auth creds via include vars by group name var
You could use template env vars with jinja template too
https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html
https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html
https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html
ansible-playbook -i 127.0.0.1 ansible-playbook site.yml --limit datacenter2 -f 10
Using if or lookup from env in jinja vars
--- - name: -Test- hosts: local vars: my_group_var: False # my_group_var: True tasks: - name: Prepare vars file from template. template: src=/tmp/vars.yaml.j2 dest=/tmp/vars.yaml - name: Include vars include_vars: "/tmp/vars.yaml"
The content of example jinja template /tmp/vars.yaml.j2 is:
{% if my_group_var %} test: var1: value var2: value {% else %} test: var1: other_value var2: other_value {% endif %}