79 lines
2.1 KiB
YAML
79 lines
2.1 KiB
YAML
---
|
|
- name: Deploy NetBox with Docker Compose
|
|
hosts: netbox
|
|
become: yes
|
|
gather_facts: yes
|
|
|
|
pre_tasks:
|
|
- name: Include vault variables
|
|
include_vars:
|
|
dir: ../inventory/group_vars
|
|
|
|
- name: Verify Ubuntu distribution
|
|
fail:
|
|
msg: "This playbook only supports Ubuntu distributions"
|
|
when: ansible_distribution != "Ubuntu"
|
|
tags: always
|
|
|
|
- name: Display deployment information
|
|
debug:
|
|
msg:
|
|
- "Deploying NetBox to {{ inventory_hostname }}"
|
|
- "OS: {{ ansible_distribution }} {{ ansible_distribution_version }}"
|
|
- "Architecture: {{ ansible_architecture }}"
|
|
- "Installation directory: {{ netbox_install_dir }}"
|
|
tags: always
|
|
|
|
roles:
|
|
- role: system-update
|
|
tags:
|
|
- system-update
|
|
- updates
|
|
- packages
|
|
|
|
- role: docker-install
|
|
tags:
|
|
- docker-install
|
|
- docker
|
|
- containers
|
|
|
|
- role: traefik
|
|
tags:
|
|
- traefik-deploy
|
|
- traefik
|
|
- reverse-proxy
|
|
|
|
- role: netbox-deploy
|
|
tags:
|
|
- netbox-deploy
|
|
- netbox
|
|
- application
|
|
|
|
post_tasks:
|
|
- name: Display NetBox access information
|
|
debug:
|
|
msg:
|
|
- "NetBox deployment completed successfully!"
|
|
- "Access NetBox at: https://{{ netbox_domain }}"
|
|
- "Traefik Dashboard at: https://{{ traefik_domain }}:{{ traefik_dashboard_port }}"
|
|
- "Default admin credentials:"
|
|
- " Username: {{ netbox_superuser_name }}"
|
|
- " Email: {{ netbox_superuser_email }}"
|
|
- " Password: {{ netbox_superuser_password }}"
|
|
- "Installation directory: {{ netbox_install_dir }}"
|
|
- "Data directory: {{ netbox_data_dir }}"
|
|
- "Traefik installation directory: {{ traefik_install_dir }}"
|
|
tags: always
|
|
|
|
- name: Show Docker Compose status
|
|
command: docker compose ps
|
|
args:
|
|
chdir: "{{ netbox_install_dir }}"
|
|
register: docker_compose_status
|
|
changed_when: false
|
|
tags: always
|
|
|
|
- name: Display Docker Compose status
|
|
debug:
|
|
var: docker_compose_status.stdout_lines
|
|
tags: always
|