ansible-ops-management/role-rocky-netbox.yml

66 lines
1.7 KiB
YAML
Raw Normal View History

2024-03-23 06:24:10 +00:00
---
# MirrorManager2
- name: Install and configure netbox
hosts: netbox
become: false
vars_files:
# This playbook requires vaults!
# vars/vaults/hostman.yml
# vars/mounts/netbox.yml # we don't know if we'll have uploads
- vars/vaults/netbox.yml
- vars/netbox.yml
# This is to try to avoid the handler issue in pre/post tasks
2024-03-23 06:24:10 +00:00
handlers:
- import_tasks: handlers/main.yml
pre_tasks:
- name: Check if ansible cannot be run here
stat:
path: /etc/no-ansible
register: no_ansible
- name: Verify if we can run ansible
ansible.builtin.assert:
that:
- "not no_ansible.stat.exists"
success_msg: "We are able to run on this node"
fail_msg: "/etc/no-ansible exists - skipping run on this node"
2024-03-23 06:24:10 +00:00
2024-04-01 06:44:11 +00:00
- name: Verify applicable vars are set
ansible.builtin.assert:
that:
- netbox_server_name
- netbox_db_host
- netbox_db_user
- netbox_db_password
- netbox_secret_key
success_msg: "Required vars set"
fail_msg: "We are missing required vars. Please ensure you have them set."
# tasks:
# - include_tasks: tasks/efs_mount.yml
# loop: "{{ mounts }}"
# tags: ["mounts"]
2024-03-23 06:24:10 +00:00
roles:
- role: rockylinux.ipagetcert
become: true
state: present
tags: ['certs']
tasks:
- name: Perform netbox installation
ansible.builtin.import_tasks: tasks/netbox/netbox.yml
post_tasks:
- name: Touching run file that ansible has ran here
become: true
ansible.builtin.file:
path: /var/log/ansible.run
state: touch
mode: '0644'
owner: root
group: root
...