Skip to content

Commit

Permalink
updated with latest netbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ds2600 committed Dec 30, 2024
1 parent 3984cff commit 5330a0a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
inventory.yml
inventory.ini
config.yml
custom_fields
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
An Ansible playbook to run through the installation process of [Netbox](https://github.com/netbox-community/netbox).

## Netbox
* v3.7.0
* v4.1.10
## Compatibility
* Ubuntu 22.04LTS

Expand All @@ -13,7 +13,7 @@ An Ansible playbook to run through the installation process of [Netbox](https://
## Current Installation Process
1. Ensure your Ansible control node can communicate with your desired Netbox server
2. Copy `inventory.example.yml` to `inventory.yml` and modify to reflect your environment
3. Copy `config.example.yml` to `config.yml` and add the Netbox superuser name, database name and database user.
3. Copy `config.example.yml` to `config.yml` and add the Netbox superuser name, and database user.
4. Run `ansible-vault create secret.yml`, enter a password for the vault and add the following variables to the file:
```yaml
db_password: <your-database-password>
Expand Down
11 changes: 6 additions & 5 deletions base/netbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,24 @@
dest: "/opt/netbox/netbox/netbox/configuration.py"

- name: "Modify ALLOWED_HOSTS"
become: yes
lineinfile:
path: "/opt/netbox/netbox/netbox/configuration.py"
search_string: "ALLOWED_HOSTS = []"
regexp: '^ALLOWED_HOSTS = \[\]$'
line: "ALLOWED_HOSTS = ['*']"
register: result
failed_when: result is failed
failed_when: result.failed

- name: "Modify database user"
lineinfile:
path: "/opt/netbox/netbox/netbox/configuration.py"
search_string: " 'USER': '', # PostgreSQL username"
regexp: "^\\s*'USER': ''\\s*,\\s*# PostgreSQL username$"
line: "\u0027USER\u0027: \u0027{{ db_user }}\u0027, # PostgreSQL username"

- name: "Modify database password"
lineinfile:
path: "/opt/netbox/netbox/netbox/configuration.py"
search_string: " 'PASSWORD': '', # PostgreSQL password"
regexp: "^\\s*'PASSWORD': ''\\s*,\\s*# PostgreSQL password$"
line: "\u0027PASSWORD\u0027: \u0027{{ db_password }}\u0027, # PostgreSQL password'}}"

- name: "Generate Netbox Secret Key"
Expand All @@ -99,6 +100,6 @@
- name: "Modify secret key"
lineinfile:
path: "/opt/netbox/netbox/netbox/configuration.py"
search_string: "SECRET_KEY = ''"
regexp: "^\\s*SECRET_KEY = ''\\s*$"
line: "SECRET_KEY = '{{ secret_key.stdout }}'"

6 changes: 6 additions & 0 deletions base/superuser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---
- name: "Logging"
lineinfile:
path: "/tmp/netbox-logs/netbox_upgrade.log"
line: "==== SUPERUSER.YML ===="
create: yes
- name: "Checking for previous superuser registration"
become: yes
stat:
path: "/tmp/netbox-logs/superuser_created"
register: superuser_beacon
Expand Down
4 changes: 2 additions & 2 deletions config.example.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
# Database information
db_user: <database-user>
db_name: <database-name>
db_name: netbox

# Netbox Superuser information
nb_superuser: <netbox-superuser>

# Netbox version
netbox_vers: 3.7.0
netbox_vers: 4.1.10

0 comments on commit 5330a0a

Please sign in to comment.