-
Notifications
You must be signed in to change notification settings - Fork 13
/
pb_nautobot_install.yml
148 lines (129 loc) · 4.33 KB
/
pb_nautobot_install.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
- hosts: "localhost"
connection: "local"
vars:
nautobot_root: "{{ lookup('env', 'NAUTOBOT_ROOT') }}"
nautobot_db_name: "{{ lookup('env', 'DB_NAME') }}"
nautobot_db_username: "{{ lookup('env', 'DB_USER') }}"
nautobot_db_password: "{{ lookup('env', 'DB_PASSWORD') }}"
allowed_hosts:
- "*"
tasks:
- name: "RUN SYSTEMCTL DAEMON-RELOAD"
ansible.builtin.command: "systemctl daemon-reload"
- name: "CREATE NAUTOBOT GROUP"
ansible.builtin.group:
name: "nautobot"
state: "present"
- name: "CREATE NAUTOBOT USER"
ansible.builtin.user:
name: "nautobot"
comment: "Nautobot User"
group: "nautobot"
shell: "/bin/bash"
home: "{{ nautobot_root }}"
system: "yes"
- name: "UPDATE SUPERVISORD.CONF"
ansible.builtin.template:
src: "supervisord.conf"
dest: "/etc/supervisord.conf"
owner: "root"
group: "root"
mode: "0640"
- name: "UPDATE UWSGI.INI"
ansible.builtin.template:
src: "uwsgi.ini"
dest: "/opt/nautobot/uwsgi.ini"
owner: "nautobot"
group: "nautobot"
mode: "0640"
- name: "START REDIS"
ansible.builtin.service:
name: "redis-server"
state: "started"
- name: "UPDATE PG_HBA.CONF"
ansible.builtin.template:
src: "pg_hba.conf"
dest: "/etc/postgresql/14/main/pg_hba.conf"
owner: "postgres"
group: "postgres"
mode: "0600"
register: "hba_update"
- name: "RESTART POSTGRESQL"
ansible.builtin.service:
name: "postgresql"
state: "restarted"
when: "hba_update.changed"
- name: "CREATE NAUTOBOT DATABASE"
community.postgresql.postgresql_db:
name: "nautobot"
state: "present"
- name: "CREATE NAUTOBOT DATABASE USER AND GRANT PRIVILEGES TO DATABASE"
community.postgresql.postgresql_user:
db: "{{ nautobot_db_name }}"
name: "{{ nautobot_db_username }}"
password: "{{ nautobot_db_password }}"
priv: "ALL"
state: "present"
- name: "INSTALL NAUTOBOT AND PLUGINS"
ansible.builtin.pip:
name: "{{ nautobot_item }}"
virtualenv: "{{ nautobot_root }}"
virtualenv_command: "python3 -m venv"
loop:
- "nautobot=={{ lookup('env', 'NAUTOBOT_VERSION') }}"
- "nautobot-device-onboarding"
- "nautobot-circuit-maintenance"
- "nautobot-data-validation-engine"
- "nautobot-capacity-metrics"
- "nautobot-golden-config"
- "nautobot-plugin-nornir"
- "nautobot-ssot"
- "nautobot-device-lifecycle-mgmt"
- "nautobot-firewall-models"
- "nautobot-bgp-models"
- "nautobot-welcome-wizard"
- "nautobot-floor-plan"
- "nautobot-design-builder"
- "supervisor"
loop_control:
loop_var: "nautobot_item"
- name: "UPDATE NAUTOBOT CONFIG"
ansible.builtin.template:
src: "nautobot_config.py"
dest: "{{ nautobot_root }}/nautobot_config.py"
owner: "nautobot"
group: "nautobot"
mode: "0644"
- name: "RUN MIGRATE"
ansible.builtin.command: "{{ nautobot_root }}/bin/nautobot-server migrate"
- name: "RUN NAUTOBOT-SERVER COLLECTSTATIC"
# yamllint disable-line rule:line-length
ansible.builtin.command: "{{ nautobot_root }}/bin/nautobot-server collectstatic"
- name: "RUN NAUTOBOT-SERVER POST_UPGRADE"
# yamllint disable-line rule:line-length
ansible.builtin.command: "{{ nautobot_root }}/bin/nautobot-server post_upgrade"
- name: "SETUP NAUTOBOT DEFAULT ACCOUNT"
ansible.builtin.command:
cmd: "{{ nautobot_root }}/bin/python3 ./templates/default_user.py"
- name: "SET NAUTOBOT DIRECTORY PERMISSIONS"
ansible.builtin.file:
path: "{{ nautobot_root }}"
owner: "nautobot"
group: "nautobot"
mode: u=rwX,g=rX,o=rX
recurse: "yes"
- name: "ADD LOAD MOCK DATA SCRIPT"
ansible.builtin.template:
src: "loaddata.sh"
dest: "/usr/local/bin/load-mock-data"
owner: "nautobot"
group: "nautobot"
mode: "0755"
- name: "UPDATE REDIS.CONF"
ansible.builtin.template:
src: "redis.conf"
dest: "/etc/redis/redis.conf"
owner: "redis"
group: "redis"
mode: "0640"