-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclean-playbook.yml
44 lines (36 loc) · 1.18 KB
/
clean-playbook.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
---
- name: Clean services
hosts: services
# become: true
vars:
scripts_destination_folder: "/root/clean_scripts/"
tasks:
- name: Create scripts_destination_folder if it doesn't exist
file:
path: "{{ scripts_destination_folder }}"
state: directory
mode: '0755'
recurse: yes
owner: root
group: root
setype: s0
- name: Read services to install
command: "cat {{ playbook_dir }}/services2install.txt"
register: services_to_install
delegate_to: localhost
- name: Copy scripts
copy:
src: "{{ item }}/clean_{{ item }}.sh"
dest: "{{ scripts_destination_folder }}"
loop: "{{ services_to_install.stdout_lines }}"
- name: Make script executable
shell: chmod +x {{ scripts_destination_folder }}clean_{{ item }}.sh
loop: "{{ services_to_install.stdout_lines }}"
- name: Execute clean script
shell: "{{ scripts_destination_folder }}clean_{{ item }}.sh"
loop: "{{ services_to_install.stdout_lines }}"
- name: Remove scripts folder
file:
path: "{{ scripts_destination_folder }}"
state: absent
# Add more tasks as needed