-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateApplications.yml
82 lines (68 loc) · 2.31 KB
/
updateApplications.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
---
- hosts: REPO1
gather_facts: no
tasks:
- name: Fetch files from REPO to control node
ansible.windows.win_find:
paths: C:\temp
patterns: [ '*.ini' ]
register: files_matched
tags: copy
- name: Fetch files from REPO to control node
run_once: yes
fetch: src=C:\\temp\\{{ item.filename }} dest=/root/playbook/INI/{{ item.filename }} flat=yes
with_items:
- '{{ files_matched.files }}'
tags: copy
- hosts: LIN
gather_facts: no
tasks:
- block: # Application 1
- name: set Application name
set_fact:
appname: 'test1.ini'
- name: get file stat to be able to perform a check in the following task
local_action: stat path=/root/playbook/INI/{{ appname }}
register: file
- name: Copy application file to respective directory in remote host
copy: src=/root/playbook/INI/{{ appname }} dest=/tmp/{{ appname }}
when: file.stat.exists
- name: Restart service
ansible.builtin.service:
name: crond
state: restarted
when: file.stat.exists
tags: lincopy
- hosts: WIN
gather_facts: no
tasks:
- block: # Application 1
- name: set Application name
set_fact:
appname: 'test1.ini'
- name: get file stat to be able to perform a check in the following task
local_action: stat path=/root/playbook/INI/{{ appname }}
register: file
- name: Copy application file to respective directory in remote host
ansible.windows.win_copy: src=/root/playbook/INI/{{ appname }} dest="C:\Program Files\Nutanix\{{ appname }}"
when: file.stat.exists
- name: Restart service
ansible.windows.win_service:
name: schedule
state: restarted
ignore_errors: yes
when: file.stat.exists
tags: wincopy
- hosts: localhost
gather_facts: no
tasks:
- name: find ini files glob
find:
paths: /root/playbook/INI
patterns: "*.ini"
register: files_to_delete
- name: clenaup ini file in control node
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ files_to_delete.files }}"