This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat inventory.yml | |
all: | |
children: | |
# empty | |
python: | |
hosts: | |
test-python-app-01: | |
gitlab: | |
hosts: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree | |
. | |
├── replace.yml | |
└── test.txt | |
0 directories, 2 files | |
$ cat test.txt | |
PASS_MAX_DAYS 99999 | |
PASS_MIN_DAYS 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree | |
. | |
├── playbook.yml | |
└── roles | |
└── test | |
├── defaults | |
│ └── main.yml | |
└── tasks | |
└── main.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat inventory.yml | |
--- | |
my_group: | |
hosts: | |
server1: | |
ansible_host: www.server1.com | |
server2: | |
vars: | |
var1: 100.100.1.1 | |
var2: abc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree | |
. | |
├── inventories | |
│ └── test | |
│ └── hosts.yml | |
├── playbook.yml | |
├── vars.yml | |
└── vault.yml | |
2 directories, 4 files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
become: false | |
gather_facts: false | |
vars: | |
example_list: [{"key1":"value_of_first_key"},{"key2":"value_of_second_key"}] | |
tasks: | |
- name: print user records |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- block: | |
- name: Execute wsadmin | |
ansible.builtin.command: "script.sh {{ argument }}" | |
register: result | |
failed_when: result.stdout is search('This resulted in error') | |
rescue: | |
- name: Status | |
ansible.builtin.debug: | |
msg: "WARNING: THERE IS AN ERROR!!!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat group_vars/your_group.yml | |
images: | |
- nginx | |
- ubuntu | |
$ cat playbook.yml | |
- name: pull images | |
hosts: your_group | |
tasks: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Debug my vars | |
vars: | |
var1: {{ result.meta.appname }} | |
var2: {{ result.meta.vipport }} | |
ansible.buitin.debug: | |
msg: | |
- "{{ var1 }}" | |
- "{{ var2 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible --version | |
ansible [core 2.14.1] | |
config file = None | |
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] | |
ansible python module location = /tmp/test/.venv/lib/python3.10/site-packages/ansible | |
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections | |
executable location = /tmp/test/.venv/bin/ansible | |
python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] (/tmp/test/.venv/bin/python3.10) | |
jinja version = 3.1.2 | |
libyaml = True |