Files
ilnmors-homelab/ansible/convention.yaml
T
2026-06-17 13:17:24 +09:00

42 lines
1.0 KiB
YAML

---
# String values need `""`
# Task names, boolean values, environment names, decimal numbers don't need `""`
- name: Convention task
delegate_to: "host"
delegate_facts: true
environment:
env: "value"
ansible.builtin.file:
# Identifier: name, src, dest, url, etc.
path: "/example/path"
# state parameters
state: "directory"
owner: "root"
group: "root"
mode: "0640"
# optional parameters
recurse: true
loop:
- "list"
loop_control:
label: "{{ item }}"
become: true
# default become user is root
become_user: "user"
when: condition.stat.exists
changed_when: condition.rc != 0
failed_when: condition.rc == 0
register: "convention_task"
notify: "notification_example"
listen: "notification_example"
no_log: true
run_once: true
# Ensure execution even if it fails (it prints errors on the screen, but it ignores them)
ignore_errors: true
tags:
- "always"
- "init"
- "site"
- "[service_name]"
# when: "'tags' is not in ansible_run_tags"