Skip to content

Instantly share code, notes, and snippets.

View zeitounator's full-sized avatar

Olivier Clavel zeitounator

View GitHub Profile
$ pyenv virtualenv 3.12.4 test_ansible_lint
$ pyenv activate test_ansible_lint
(test_ansible_lint)$ pip install ansible ansible-lint
Collecting ansible
Using cached ansible-10.1.0-py3-none-any.whl.metadata (8.2 kB)
Collecting ansible-lint
Using cached ansible_lint-24.6.0-py3-none-any.whl.metadata (5.6 kB)
Collecting ansible-core~=2.17.1 (from ansible)
---
- name: Fetch tar file from sibling_node
hosts: '{{sibling_node.stdout}}"
max_fail_percentage: "{{ vnf_fail_ratio }}"
remote_user: root
vars_files:
- vars/global_var.yml
tasks:
- include_tasks: tasks/common/fetchdir.yml
vars:
---
all:
hosts:
host1.example.com:
file_name: "app1.jar"
SERVER_PATH: "/apps1"
host2.example.com:
file_name: "app2.jar"
SERVER_PATH: "/apps2"
$ cat test.yml
---
- hosts: localhost
tasks:
- name: Write ip4 adrees in a file
ansible.builtin.lineinfile:
line: "My ip4 is: {{ ansible_enp5s0.ipv4.address }}"
dest: /tmp/test/toto.txt
create: true
$ tree
.
├── test.yml
├── users_initial.yml
├── users_modify.yml
└── Vagrantfile
0 directories, 4 files
$ cat Vagrantfile
$ cat toto.yml
$ANSIBLE_VAULT;1.1;AES256
32353335396261646339343466646261306239633333366365663862353062653632653633656162
6464663731366136633131646531303063366332633734370a653464373830666666343930393564
39393162396564356336336339666666383432323738376566626434393461376334656664396339
6461363530383238340a376333306631383762323134303931393938653837633263386664633830
61383664303562386131306234333238396434316636343230633231386138613264383566363432
6165626266626437653735383835663564313162633265643964
$ cat testtoto.py
$ # Test project structure
$ tree
.
├── test.yml
├── users_initial.yml
└── users_modify.yml
0 directories, 3 files
$ tree
.
├── fake_command
├── test_as_json_default_stdout.yml
└── test_as_lines_yaml_stdout.yml
0 directories, 3 files
$ cat fake_command
#!/usr/bin/env bash
$ ansible --version
ansible [core 2.16.1]
config file = None
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/user/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /home/user/.local/bin/ansible
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
$ tree .
.
├── demo.yml
├── unreachable_nodes-1.yml
└── unreachable_nodes-2.yml
0 directories, 3 files
$ cat unreachable_nodes-1.yml
---