forked from kpjinuprabhakar/opsrampagent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagent-install-uninstall.yml
63 lines (63 loc) · 2.9 KB
/
agent-install-uninstall.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
---
- hosts: "{{ hostlist | default('all') }}"
gather_facts: yes
vars:
typeOfExecution: "{{ executionType | default('install') | lower }}"
removeandinstall: "{{ reinstall | default('no') | lower }}"
agentType: "{{ isnonroot | default('no') | lower }}"
customUser: "{{ agentuser | default('') }}"
internal_cmd: ""
tasks:
- name: myTest1
include_vars:
file: roles/common/vars/agentconfig.yml
name: config
run_once: true
- name:
block:
- name: myTest2
set_fact:
agent_cmd: " -K {{ config['api_key'] }} -S {{ config['api_secret'] }} -s {{ config['api_server'] }} -c {{ config['client_id'] }} -f {{ config['features'] }}"
delegate_to: 127.0.0.1
run_once: true
when: config['connectionType'] != "proxy"
- name: myTest3
set_fact:
agent_cmd: " -K {{ config['api_key'] }} -S {{ config['api_secret'] }} -s {{ config['api_server'] }} -c {{ config['client_id'] }} -m {{ config['connectionType'] }} -x {{ config['proxy_server'] }} -p {{ config['proxy_port'] }} -t {{ config['proxy_proto'] }} -f {{ config['features'] }}"
delegate_to: 127.0.0.1
run_once: true
when: config['connectionType'] == "proxy"
- name: myTest4
set_fact:
agent_cmd: " -K {{ config['api_key'] }} -S {{ config['api_secret'] }} -s {{ config['api_server'] }} -c {{ config['client_id'] }} -m {{ config['connectionType'] }} -x {{ config['proxy_server'] }} -p {{ config['proxy_port'] }} -t {{ config['proxy_proto'] }} -U {{ config['proxy_user'] }} -P {{ config['proxy_passwd'] }} -f {{ config['features'] }}"
delegate_to: 127.0.0.1
run_once: true
when: config['connectionType'] == "proxy" and config['proxy_user'] != "PROXY_USERNAME" and config['proxy_passwd'] != "PROXY_PASSWORD"
- name: myTest5
set_fact:
internal_cmd: "echo {{ ansible_password }} | sudo -S "
ignore_errors: yes
no_log: True
when: ansible_user != "root"
- name: Getting system python path
shell: if [ "$(command -v python)" != '' ];then command -v python; elif [ "$(command -v python2)" != '' ];then command -v python2; else command -v python3; fi
register: pythonpath
delegate_to: 127.0.0.1
run_once: true
ignore_errors: yes
- name: Checking/downloading latest agent packages
shell: "{{ pythonpath.stdout }} roles/common/files/downloadpackages.py {{ agent_cmd }}"
delegate_to: 127.0.0.1
run_once: true
- name: myTest6
include_vars:
file: roles/common/vars/agentversion.yml
name: version
run_once: true
- name: myTest7
include_tasks: roles/agent-install-uninstall/install/tasks/deployagent.yml
when: version['agentVersion'] != "none"
when: typeOfExecution == "install"
- name: myTest8
include_tasks: "roles/agent-install-uninstall/uninstall/tasks/{{ (ansible_facts['os_family'] | lower) }}.yml"
when: typeOfExecution == "uninstall"