-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path100.9_playbook-uninstall-windows_agent_s3.yaml
92 lines (79 loc) · 2.79 KB
/
100.9_playbook-uninstall-windows_agent_s3.yaml
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
85
86
87
88
89
90
91
92
# Example Playbok to deploy agents
- name: Deploy App Agent
hosts: windows
vars:
agent_src: /tmp
s3_bucket: dps-products
s3_host: http://ansible.demo.local:9000
access_key: minioadmin
secret_key: Password123!
s3_container: powerprotect
release: 19.17
package:
vars_files:
- ./vars/main.yml
- ./vars/agents_vars.yaml
- "{{ agent_src }}/agents.yaml"
tasks:
- name: Create a directory if it does not exist
ansible.builtin.file:
path: "{{ agent_src }}"
state: directory
#mode: '0755'
delegate_to: localhost
- name: Copy Latest Agent Version from S3
amazon.aws.aws_s3:
bucket: "{{ s3_bucket}}"
object: "{{ s3_container }}/{{ release }}/agents/agents.yaml"
dest: "{{ agent_src }}/agents.yaml"
mode: get
encrypt: false
endpoint_url: "{{ s3_host }}"
access_key: "{{ access_key }}"
secret_key: "{{ secret_key }}"
when: not ansible_check_mode
delegate_to: localhost
- name: Include Agent Vars from S3
ansible.builtin.include_vars:
dir: "{{ agent_src }}"
files_matching: agents.yaml
- name: Create a directory if it does not exist
ansible.builtin.file:
path: "{{ agent_src }}/{{ app_agent | dirname }}"
state: directory
mode: '0755'
delegate_to: localhost
- name: Copy Agents from S3
amazon.aws.aws_s3:
bucket: "{{ s3_bucket}}"
object: "{{ s3_container }}/{{ release }}/agents/{{ app_agent }}"
dest: "{{ agent_src }}/{{ app_agent }}"
mode: get
encrypt: false
endpoint_url: "{{ s3_host }}"
access_key: "{{ access_key }}"
secret_key: "{{ secret_key }}"
when: not ansible_check_mode
delegate_to: localhost
- name: Copy agent to {{ ansible_fqdn }}
ansible.windows.win_copy:
src: "{{ agent_src }}/{{ app_agent }}"
dest: C:/Temp/
- name: Unzip Agents
community.windows.win_unzip:
src: "C:/Temp/{{ app_agent | basename }}"
dest: C:/swdist
register: unzip
- name: Find files in path based on regex pattern
ansible.windows.win_find:
paths: c:/swdist/ntx64, c:/swdist/win_x64
patterns: "*-{{ agent_release }}.exe"
register: find_file
- name: "Remove with fsagent {{ find_file.files[0].path }} on {{ ansible_fqdn }}"
ansible.windows.win_command:
cmd: '"{{ find_file.files[0].path }}" /s /uninstall UnInstallBBBWT="1" PPDMHostName="{{ ppdm_fqdn }}" UnInstallPPDMAgent="1"'
when: app_agent == fs_agent_windows
- name: "Remove with msappagent {{ find_file.files[0].path }} on {{ ansible_fqdn }}"
ansible.windows.win_command:
cmd: '"{{ find_file.files[0].path }}" /q /uninstall PPDMHostname={{ ppdm_fqdn }} UninstallAgentService="1"'
when: app_agent == msapp_agent_windows