This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrole.yml
84 lines (71 loc) · 2.32 KB
/
role.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
- name: Install Ansible role boilerplate
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Verify user input for required variables
tags: always
assert:
that:
- role_name is defined
- role_path is defined
- role_prefix|default('ansible') in role_allowed_role_prefixes
- name: Install Ansible role boilerplate
tags: role
register: role_install_ansible_role_boilerplate
command: "ansible-galaxy init --init-path {{ role_path }} {{ role_name_final }}"
args:
creates: "{{ role_dest }}"
- name: Read generated meta/main.yml
tags: role
set_fact:
role_meta_main: "{{ lookup('file', role_dest + '/meta/main.yml') }}"
- name: Configure force flag
tags: role
when: role_install_ansible_role_boilerplate.changed
set_fact:
force: true
- name: Ensure role directories
tags: role
with_items: "{{ role_dirs }}"
file:
state: directory
dest: "{{ role_dest }}/{{ item }}"
- name: Install static files
tags: role
with_items:
- "{{ role_files|selectattr('src', 'defined')|list }}"
- "{{ role_files|selectattr('content', 'defined')|list }}"
copy:
src: "{{ item.src|default(omit) }}"
dest: "{{ role_dest }}/{{ item.dest|mandatory }}"
mode: "{{ item.mode|default(0600) }}"
force: "{{ force|default(item.force)|default(false) }}"
content: "{{ item.content|default(omit) }}"
- name: Install templated files
tags: role
with_items: "{{ role_files|selectattr('template', 'defined')|list }}"
template:
src: "templates/{{ item.template }}"
dest: "{{ role_dest }}/{{ item.dest|mandatory }}"
mode: "{{ item.mode|default(0600) }}"
force: "{{ force|default(item.force)|default(false) }}"
- name: Ensure state absent
tags: role
with_items: "{{ role_files_absent }}"
file:
state: absent
dest: "{{ role_dest }}/{{ item }}"
- name: Include tasks to manage git
tags:
- role
- git
when: role_manage_with_git
include: tasks/git.yml
vars:
target: "{{ role_dest }}"
- name: baem!
tags: role
debug:
msg: "Find the Ansible role at {{ role_dest }}"