Skip to content

Commit

Permalink
Single pip Install
Browse files Browse the repository at this point in the history
  • Loading branch information
User Alpha authored and lae committed Mar 10, 2020
1 parent 837faf2 commit c62163b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode/
.history
*.retry
*.code-workspace
71 changes: 31 additions & 40 deletions tasks/deploy_netbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,29 @@
register: _netbox_virtualenv_setup
until: _netbox_virtualenv_setup is succeeded

- name: Install django-rq
- name: Install additional pip Packages
pip:
name: "django-rq"
virtualenv: "{{ netbox_virtualenv_path }}"
name:
- "{{ netbox_napalm_packages if netbox_napalm_enabled else [] }}"
- "{{ django-auth-ldap if netbox_ldap_enabled else [] }}"
- "{{ django-storages if netbox_config.STORAGE_BACKEND else [] }}"
- "{{ apache-libcloud if netbox_config.STORAGE_BACKEND == 'storages.backends.apache_libcloud.LibCloudStorage' else [] }}"
- "{{ django-storages[azure] if netbox_config.STORAGE_BACKEND == 'storages.backends.azure_storage.AzureStorage' else [] }}"
- "{{ django-storages[dropbox] if netbox_config.STORAGE_BACKEND == 'storages.backends.dropbox.DropBoxStorage' else [] }}"
- "{{ django-storages[google] if netbox_config.STORAGE_BACKEND == 'storages.backends.gcloud.GoogleCloudStorage' else [] }}"
state: present
vars:
ansible_python_interpreter: "{{ netbox_python_binary }}"
environment:
PATH: "/usr/local/bin:{{ _path }}"
become: True
become_user: "{{ netbox_user }}"
retries: 2
register: _netbox_django_rq_install
until: _netbox_django_rq_install is succeeded
register: _netbox_pip_additional_install
until: _netbox_pip_additional_install is succeeded
when: (netbox_napalm_enabled) or
(netbox_ldap_enabled) or
(netbox_config.STORAGE_BACKEND)

- name: Generate NetBox configuration file
template:
Expand All @@ -61,44 +75,21 @@
notify:
- reload netbox.service

- block:
- name: Install django-auth-ldap if LDAP is enabled
pip:
name: django-auth-ldap
virtualenv: "{{ netbox_virtualenv_path }}"
become: True
become_user: "{{ netbox_user }}"
retries: 2
register: _netbox_django_auth_ldap_install
until: _netbox_django_auth_ldap_install is succeeded

- name: Generate LDAP configuration for NetBox if enabled
template:
src: "{{ netbox_ldap_config_template }}"
dest: "{{ netbox_shared_path }}/ldap_config.py"
owner: "{{ netbox_user }}"
group: "{{ netbox_group }}"
mode: 0640
validate: "{{ netbox_virtualenv_path }}/bin/python -c \"import py_compile,os; f=r'%s';\
c='/tmp/' + os.path.basename(os.path.dirname(f)) + '-' + os.path.basename(f) + 'c';\
py_compile.compile(f, c); os.remove(c)\""
notify:
- reload netbox.service
- name: Generate LDAP configuration for NetBox if enabled
template:
src: "{{ netbox_ldap_config_template }}"
dest: "{{ netbox_shared_path }}/ldap_config.py"
owner: "{{ netbox_user }}"
group: "{{ netbox_group }}"
mode: 0640
validate: "{{ netbox_virtualenv_path }}/bin/python -c \"import py_compile,os; f=r'%s';\
c='/tmp/' + os.path.basename(os.path.dirname(f)) + '-' + os.path.basename(f) + 'c';\
py_compile.compile(f, c); os.remove(c)\""
notify:
- reload netbox.service
when:
- netbox_ldap_enabled

- name: Install napalm if NAPALM integration is enabled
pip:
name: "{{ netbox_napalm_packages }}"
virtualenv: "{{ netbox_virtualenv_path }}"
when:
- netbox_napalm_enabled
become: True
become_user: "{{ netbox_user }}"
retries: 2
register: _netbox_napalm_install
until: _netbox_napalm_install is succeeded

- name: Symlink NetBox configuration file into the active NetBox release
file:
src: "{{ netbox_shared_path }}/configuration.py"
Expand Down

0 comments on commit c62163b

Please sign in to comment.