-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreflight.yml
113 lines (94 loc) · 2.96 KB
/
preflight.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
# EDGEX NODE
- name: Install Docker
hosts: edgex_node
become: true
pre_tasks:
- name: Fails if no telegram token is defined
fail:
msg: telegram_token is not defined
when: telegram_token is not defined
- name: Fails if no telegram channel_id is defined
fail:
msg: telegram_channel_id is not defined
when: telegram_channel_id is not defined
- name: Update packages
ansible.builtin.apt:
update_cache: true
roles:
- role: geerlingguy.docker
vars:
docker_install_compose_plugin: false
docker_compose_package: docker-compose-plugin
docker_compose_package_state: present
tasks:
- name: Create working directory
ansible.builtin.file:
path: /usr/local/edgex-runtime/device-snmp/devices
state: directory
mode: '755'
- name: Create working directory
ansible.builtin.file:
path: /usr/local/edgex-runtime/device-snmp/device-profiles
state: directory
mode: '755'
- name: Create working directory
ansible.builtin.file:
path: /usr/local/edgex-runtime
state: directory
mode: '755'
- name: Download docker compose file for edgex runtime
ansible.builtin.template:
src: docker-compose.yml.j2
dest: /usr/local/edgex-runtime/docker-compose.yml
- name: Copy device profile files
ansible.builtin.copy:
src: '{{ item }}'
dest: /usr/local/edgex-runtime/device-snmp/device-profiles/
loop: "{{ query('fileglob', 'edgex_metadata/*') }}"
- name: Copy device files
ansible.builtin.template:
src: '{{ item[1] }}'
dest: '/usr/local/edgex-runtime/device-snmp/devices/{{ name }}.yml'
mode: '644'
vars:
address: "{{ hostvars[item[0]].internal_address }}"
name: "{{ hostvars[item[0]].ansible_hostname }}"
loop: "{{ groups['iot_nodes'] | product(query('fileglob', 'device_templates/*'))}}"
- name: Install monitoring application
ansible.builtin.copy:
src: monitor
dest: /usr/local/
- name: Build docker image
community.docker.docker_image_build:
name: monitor:latest
path: /usr/local/monitor
dockerfile: Dockerfile
rebuild: always
- name: start edgex runtime
community.docker.docker_compose_v2:
project_src: /usr/local/edgex-runtime
state: present
register: result
retries: 5
delay: 10
# IOT DEVICES
- name: Provision iot devices
hosts: iot_nodes
become: true
tasks:
- name: Install snmp agent
ansible.builtin.apt:
name: snmpd
state: present
update_cache: true
- name: enable agent on all interfaces
ansible.builtin.template:
src: snmpd.conf.j2
dest: /etc/snmp/snmpd.conf
vars:
name: "{{ ansible_hostname }}"
- name: Restart snmp agent
ansible.builtin.service:
name: snmpd
state: restarted