Repository navigation
Expand file tree
/
Copy pathplaybook.yaml
More file actions
53 lines (48 loc) · 1.65 KB
/
Copy pathplaybook.yaml
File metadata and controls
53 lines (48 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- name: configure dotfiles
hosts: localhost
gather_facts: false
tasks:
- name: sync repo
ansible.builtin.command:
cmd: git pull
chdir: "{{ playbook_dir }}"
register: git_pull
# Rebasing a branch that is ahead says "Current branch main is up to date." instead.
changed_when: "'up to date' not in git_pull.stdout"
tags: always
- name: sync submodules
ansible.builtin.command:
cmd: git submodule update --init
chdir: "{{ playbook_dir }}"
register: git_submodule
changed_when: git_submodule.stdout | length > 0
tags: always
- name: find component tasks
ansible.builtin.find:
paths: "{{ playbook_dir }}"
patterns: tasks.yaml
recurse: true
depth: 2
register: task_files
tags: always
- name: include component tasks
ansible.builtin.include_tasks:
file: "{{ tasks_file.path }}"
apply:
tags: "{{ tasks_file.path | dirname | basename }}"
vars:
component: "{{ tasks_file.path | dirname | basename }}"
loop: "{{ task_files.files | sort(attribute='path') }}"
loop_control:
loop_var: tasks_file
label: "{{ tasks_file.path | dirname | basename }}"
tags: always
# After the components, so a first run has already installed prek.
- name: install git hooks
ansible.builtin.command:
cmd: prek install
chdir: "{{ playbook_dir }}"
when: lookup('ansible.builtin.pipe', 'command -v prek || true') | length > 0
# prek prints the same lines whether or not the hooks were already there.
changed_when: false
tags: always