|
86 | 86 | - restart netbox.service |
87 | 87 | - restart netbox-rqworker.service |
88 | 88 |
|
89 | | -- name: Generate NetBox configuration file |
90 | | - template: |
91 | | - src: templates/configuration.py.j2 |
92 | | - dest: "{{ netbox_shared_path }}/configuration.py" |
93 | | - owner: "{{ netbox_user }}" |
94 | | - group: "{{ netbox_group }}" |
95 | | - mode: 0640 |
96 | | - validate: "{{ netbox_virtualenv_path }}/bin/python -c \"import py_compile,os; f=r'%s';\ |
97 | | - c='/tmp/' + os.path.basename(os.path.dirname(f)) + '-' + os.path.basename(f) + 'c';\ |
98 | | - py_compile.compile(f, c); os.remove(c)\"" |
99 | | - notify: |
100 | | - - reload netbox.service |
101 | | - - restart netbox-rqworker.service |
| 89 | +- name: NetBox Configuration |
| 90 | + block: |
| 91 | + # configuration.py |
| 92 | + - name: Generate NetBox configuration file |
| 93 | + ansible.builtin.template: |
| 94 | + src: templates/configuration.py.j2 |
| 95 | + dest: "{{ netbox_shared_path }}/configuration.py" |
| 96 | + owner: "{{ netbox_user }}" |
| 97 | + group: "{{ netbox_group }}" |
| 98 | + mode: 0640 |
| 99 | + validate: "{{ netbox_virtualenv_path }}/bin/python -c \"import py_compile,os; f=r'%s';\ |
| 100 | + c='/tmp/' + os.path.basename(os.path.dirname(f)) + '-' + os.path.basename(f) + 'c';\ |
| 101 | + py_compile.compile(f, c); os.remove(c)\"" |
| 102 | + notify: |
| 103 | + - restart netbox-rqworker.service |
102 | 104 |
|
103 | | -- name: Generate LDAP configuration for NetBox if enabled |
104 | | - template: |
105 | | - src: "{{ netbox_ldap_config_template }}" |
106 | | - dest: "{{ netbox_shared_path }}/ldap_config.py" |
107 | | - owner: "{{ netbox_user }}" |
108 | | - group: "{{ netbox_group }}" |
109 | | - mode: 0640 |
110 | | - validate: "{{ netbox_virtualenv_path }}/bin/python -c \"import py_compile,os; f=r'%s';\ |
111 | | - c='/tmp/' + os.path.basename(os.path.dirname(f)) + '-' + os.path.basename(f) + 'c';\ |
112 | | - py_compile.compile(f, c); os.remove(c)\"" |
113 | | - notify: |
114 | | - - reload netbox.service |
115 | | - when: |
116 | | - - netbox_ldap_enabled |
| 105 | + - name: Symlink NetBox configuration file into the active NetBox release |
| 106 | + ansible.builtin.file: |
| 107 | + src: "{{ netbox_shared_path }}/configuration.py" |
| 108 | + dest: "{{ netbox_config_path }}/configuration.py" |
| 109 | + owner: "{{ netbox_user }}" |
| 110 | + group: "{{ netbox_group }}" |
| 111 | + state: link |
117 | 112 |
|
118 | | -- name: Symlink NetBox configuration file into the active NetBox release |
119 | | - file: |
120 | | - src: "{{ netbox_shared_path }}/configuration.py" |
121 | | - dest: "{{ netbox_config_path }}/configuration.py" |
122 | | - owner: "{{ netbox_user }}" |
123 | | - group: "{{ netbox_group }}" |
124 | | - state: link |
| 113 | + # ldap_config.py |
| 114 | + - name: Generate LDAP configuration for NetBox if enabled |
| 115 | + ansible.builtin.template: |
| 116 | + src: "{{ netbox_ldap_config_template }}" |
| 117 | + dest: "{{ netbox_shared_path }}/ldap_config.py" |
| 118 | + owner: "{{ netbox_user }}" |
| 119 | + group: "{{ netbox_group }}" |
| 120 | + mode: 0640 |
| 121 | + validate: "{{ netbox_virtualenv_path }}/bin/python -c \"import py_compile,os; f=r'%s';\ |
| 122 | + c='/tmp/' + os.path.basename(os.path.dirname(f)) + '-' + os.path.basename(f) + 'c';\ |
| 123 | + py_compile.compile(f, c); os.remove(c)\"" |
| 124 | + when: |
| 125 | + - netbox_ldap_enabled |
125 | 126 |
|
126 | | -- name: Symlink/Remove NetBox LDAP configuration file into/from the active NetBox release |
127 | | - file: |
128 | | - src: "{{ netbox_shared_path + '/ldap_config.py' if netbox_ldap_enabled else omit }}" |
129 | | - dest: "{{ netbox_config_path }}/ldap_config.py" |
130 | | - owner: "{{ netbox_user }}" |
131 | | - group: "{{ netbox_group }}" |
132 | | - state: "{{ 'link' if netbox_ldap_enabled else 'absent' }}" |
133 | | - notify: |
134 | | - - reload netbox.service |
| 127 | + - name: Symlink/Remove NetBox LDAP configuration file into/from the active NetBox release |
| 128 | + ansible.builtin.file: |
| 129 | + src: "{{ netbox_shared_path + '/ldap_config.py' if netbox_ldap_enabled else omit }}" |
| 130 | + dest: "{{ netbox_config_path }}/ldap_config.py" |
| 131 | + owner: "{{ netbox_user }}" |
| 132 | + group: "{{ netbox_group }}" |
| 133 | + mode: 0640 |
| 134 | + state: "{{ 'link' if netbox_ldap_enabled else 'absent' }}" |
135 | 135 |
|
136 | | -# local_settings.py |
137 | | -- name: Copy NetBox local_settings.py into shared (ignore if it doesn't exist) |
138 | | - ansible.builtin.copy: |
139 | | - src: "{{ netbox_local_settings_file }}" |
140 | | - dest: "{{ netbox_shared_path }}/local_settings.py" |
141 | | - owner: "{{ netbox_user }}" |
142 | | - group: "{{ netbox_group }}" |
143 | | - when: |
144 | | - - netbox_local_settings_file is defined |
145 | | - notify: |
146 | | - - reload netbox.service |
| 136 | + # local_settings.py |
| 137 | + - name: Copy NetBox local_settings.py into shared (ignore if it doesn't exist) |
| 138 | + ansible.builtin.copy: |
| 139 | + src: "{{ netbox_local_settings_file }}" |
| 140 | + dest: "{{ netbox_shared_path }}/local_settings.py" |
| 141 | + owner: "{{ netbox_user }}" |
| 142 | + group: "{{ netbox_group }}" |
| 143 | + mode: 0640 |
| 144 | + when: |
| 145 | + - netbox_local_settings_file is defined |
147 | 146 |
|
148 | | -- name: Symlink/Remove NetBox local_settings.py file into/from the active NetBox release |
149 | | - ansible.builtin.file: |
150 | | - src: "{{ netbox_shared_path }}/local_settings.py" |
151 | | - dest: "{{ netbox_config_path }}/local_settings.py" |
152 | | - owner: "{{ netbox_user }}" |
153 | | - group: "{{ netbox_group }}" |
154 | | - state: "{{ 'link' if netbox_local_settings_file is defined else 'absent' }}" |
| 147 | + - name: Symlink/Remove NetBox local_settings.py file into/from the active NetBox release |
| 148 | + ansible.builtin.file: |
| 149 | + src: "{{ netbox_shared_path }}/local_settings.py" |
| 150 | + dest: "{{ netbox_config_path }}/local_settings.py" |
| 151 | + owner: "{{ netbox_user }}" |
| 152 | + group: "{{ netbox_group }}" |
| 153 | + mode: 0640 |
| 154 | + state: "{{ 'link' if netbox_local_settings_file is defined else 'absent' }}" |
155 | 155 | notify: |
156 | 156 | - reload netbox.service |
157 | 157 |
|
|
0 commit comments