Skip to content

Instantly share code, notes, and snippets.

View zeitounator's full-sized avatar

Olivier Clavel zeitounator

View GitHub Profile
$ ansible localhost -e '{"bla": "test"}' -m debug -a "msg={{ bla | type_debug == 'list' }}"
localhost | SUCCESS => {
"msg": false
}
$ ansible localhost -e '{"bla": ["test1", "test2"]}' -m debug -a "msg={{ bla | type_debug == 'list' }}"
localhost | SUCCESS => {
"msg": true
}
$ date
jeu 22 aoû 2024 18:42:38 CEST
$ crontab -l
CRON_TZ="Europe/London"
43 18 * * * echo $CRON_TZ > /tmp/toto.txt
$ cat /tmp/toto.txt
cat: /tmp/toto.txt: No such file or directory
$ 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