Skip to content

Instantly share code, notes, and snippets.

View zeitounator's full-sized avatar

Olivier Clavel zeitounator

View GitHub Profile
$ cat reg.yaml
- hosts: localhost
gather_facts: false
vars:
myconfig:
kindA:
regexp: "^exampleA.+$"
kindB:
regexp: "^exampleB.+$"
$ cat test.yml
- hosts: localhost
gather_facts: false
tasks:
- name: Test task
ansible.builtin.debug:
msg: This task runs
loop: [1,2,3,4]
when: item < 3
$ ansible --version
ansible [core 2.17.6]
config file = None
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/user/.pyenv/versions/3.13.0/envs/trashso/lib/python3.13/site-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /home/user/.pyenv/versions/trashso/bin/ansible
python version = 3.13.0 (main, Nov 9 2024, 10:01:52) [GCC 11.4.0] (/home/user/.pyenv/versions/3.13.0/envs/trashso/bin/python)
jinja version = 3.1.4
libyaml = True
$ 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