-
Notifications
You must be signed in to change notification settings - Fork 0
/
.deploy.yml
84 lines (73 loc) · 2.15 KB
/
.deploy.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
# Ansible playbook to deploy fortiwlc_exporter
---
- hosts: all
gather_facts: false
vars:
cd_environment: "{{ lookup('env', 'CI_ENVIRONMENT_SLUG') }}"
package_version: "{{ lookup('env', 'CI_COMMIT_TAG') }}"
tasks:
- name: CD environment
debug:
var: cd_environment
- name: Include vars
include_vars: "deploy/{{ cd_environment }}_vars.yml"
- name: copy RPM package to host
copy:
src: "{{ lookup('fileglob', './rpms/x86_64/fortiwlc-exporter-*.el7.x86_64.rpm') }}"
dest: /tmp/
register: copy_result
when:
- cd_environment == "testing" or cd_environment == "staging"
- name: install copied RPM package
yum:
name: "{{ copy_result.dest }}"
state: present
when:
- cd_environment == "testing" or cd_environment == "staging"
notify:
- restart fortiwlc_exporter
- name: expire yum cache to force refreshing repo info
shell: yum clean expire-cache
args:
warn: no
when:
- cd_environment == "production"
- name: install package from yum repo
yum:
name: "fortiwlc-exporter-{{ package_version }}"
state: present
allow_downgrade: yes
update_cache: yes
when:
- cd_environment == "production"
notify:
- restart fortiwlc_exporter
retries: 3
delay: 5
register: result
until: result is not failed
- name: write wlc username
lineinfile:
path: /etc/fortiwlc_exporter.yaml
line: "wlc_username: {{ wlc_username }}"
regexp: "^wlc_username:\\s"
no_log: yes
notify:
- restart fortiwlc_exporter
- name: write wlc password
lineinfile:
path: /etc/fortiwlc_exporter.yaml
line: "wlc_password: {{ wlc_password }}"
regexp: "^wlc_password:\\s"
no_log: yes
notify:
- restart fortiwlc_exporter
- name: enable fortiwlc_exporter service on boot
service:
name: fortiwlc_exporter
enabled: yes
handlers:
- name: restart fortiwlc_exporter
service:
name: fortiwlc_exporter
state: restarted