networktocode.nautobot.nautobot_server module – Manages Nautobot Server application.

Note

This module is part of the networktocode.nautobot collection (version 5.3.1).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install networktocode.nautobot. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: networktocode.nautobot.nautobot_server.

New in networktocode.nautobot 3.0.0

Synopsis

  • Manages Nautobot Server using the nautobot-server application frontend to django-admin. With the virtualenv parameter

  • all management commands will be executed by the given virtualenv installation.

Requirements

The below requirements are needed on the host that executes this module.

  • nautobot

Parameters

Parameter

Comments

args

A dictionary of the optional arguments and their values used together with the command. This translates {“name_arg”: “value_arg”} to “–name_arg value_arg”.

:ansible-option-default-bold:`Default:` :ansible-option-default:`{}`

command

The name of the Nautobot management command to run. Some command fully implemented are: createsuperuser, migrate, makemigrations, post_upgrade and collectstatic. Other commands can be entered, but will fail if they’re unknown to Nautobot or use positional arguments. The module will perform some basic parameter validation, when applicable, to the commands.

db_password

Database password used in Nautobot.

db_username

Database username used in Nautobot.

flags

A list of flags to append to the command that is passed to nautobot-server, so that [“flag1”, “flag2”] is translated to “–flag1 –flag2”.

:ansible-option-default-bold:`Default:` :ansible-option-default:`[]`

positional_args

A list of additional arguments to append to the end of the command that is passed to nautobot-server.

These are appended to the end of the command, so that [“arg1”, “arg2”] is translated to “arg1 arg2”.

:ansible-option-default-bold:`Default:` :ansible-option-default:`[]`

project_path

The path to the root of the Nautobot application where nautobot-server lives.

:ansible-option-default-bold:`Default:` :ansible-option-default:`"/opt/nautobot"`

pythonpath

A directory to add to the Python path. Typically used to include the settings module if it is located external to the application directory.

settings

The Python path to the application’s settings module, such as ‘myapp.settings’.

virtualenv

An optional path to a virtualenv installation to use while running the nautobot-server application.

Notes

Note

Examples

- name: Createsuperuser
  networktocode.nautobot.nautobot_server:
    command: "createsuperuser"
    args:
      email: "admin93@example.com"
      username: "superadmin7"
    db_password: "{{ db_password }}"
- name: Collectstatic
  networktocode.nautobot.nautobot_server:
    command: "collectstatic"
    db_password: "{{ db_password }}"
- name: Post Upgrade
  networktocode.nautobot.nautobot_server:
    command: "post_upgrade"
- name: Make Migrations for Plugin
  networktocode.nautobot.nautobot_server:
    command: "makemigrations"
    positional_args: ["my_plugin_name"]
    db_password: "{{ db_password }}"
- name: Migrate Plugin
  networktocode.nautobot.nautobot_server:
    command: "migrate"
    args:
      verbosity: 3
    flags: ["merge"]
    positional_args: ["my_plugin_name"]
    db_username: "{{ db_username }}"
    db_password: "{{ db_password }}"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

changed

cmd

out

project_path

The path to the root of the Nautobot application where nautobot-server lives.

:ansible-option-returned-bold:`Returned:` always

:ansible-option-sample-bold:`Sample:` :ansible-rv-sample-value:`"/opt/nautobot"`

Authors

  • Network to Code (@networktocode)