Skip to content

Commit

Permalink
Merge pull request #86 from nautobot/main-data
Browse files Browse the repository at this point in the history
Add load-mock-data command
  • Loading branch information
jtdub authored Sep 27, 2023
2 parents ac6486c + 7fd8d7c commit 121e848
Show file tree
Hide file tree
Showing 5 changed files with 27,931 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ The container can be built locally, if preferred.
docker run -itd --name nautobot -p 8000:8000 nautobot-lab
```

### Importing the demo dataset

The nautobot-lab container provides demo dataset similar to the Nautobot public sandbox (http://demo.nautobot.com).
This dataset can be used to quickly populate your Nautobot instance with the real life data! You can use it to view data, experiment or perform experimental or development work.

Use following command to import the data into your lab container:
```shell
docker exec -itd nautobot load-mock-data
```

!!! warning
**Importing dataset will erase your existing data**. Issuing the `load-mock-data` will result in destroying your existing dataset and importing new one.
**Dataset contains default credentials**. If you decide to import provided dataset, the dataset credentials will be used: username: `admin`, password: `admin`.

## The Default Account

The nautobot-lab container comes with a user pre-defined. The username is `demo` and its corresponding password is `nautobot`. If you choose to build your own container, you can define your own attributes for the default account by setting the following environment variables before executing the `docker build` command.
Expand Down
8 changes: 8 additions & 0 deletions pb_nautobot_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@
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"
Expand Down
18 changes: 18 additions & 0 deletions templates/loaddata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

export PGUSER="postgres"
export PGDATABASE=$DB_NAME

psql -c "DROP SCHEMA public CASCADE";
psql -c "CREATE SCHEMA public";
psql -c "GRANT ALL ON SCHEMA public TO postgres";
psql -c "GRANT ALL ON SCHEMA public TO public";
psql -c "GRANT ALL ON SCHEMA public TO ${DB_USER}";

export PGUSER=$DB_USER
export PGPASSWORD=$DB_PASSWORD

psql < {{ nautobot_root }}/templates/nautobot_backup.dump

{{ nautobot_root }}/bin/nautobot-server migrate
{{ nautobot_root }}/bin/nautobot-server invalidate all
Loading

0 comments on commit 121e848

Please sign in to comment.