feat: Introduce an Ansible common role for base system configuration, including packages, users, and Netplan networking, alongside Semaphore playbooks for system bootstrapping and Proxmox management.
This commit is contained in:
26
ansible/playbooks/semaphore/bootstrap.yml
Normal file
26
ansible/playbooks/semaphore/bootstrap.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: Register Target Host
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Verify target_host is defined
|
||||
fail:
|
||||
msg: "The 'target_host' variable must be defined (e.g. 192.168.1.10)"
|
||||
when: target_host is not defined
|
||||
|
||||
- name: Add target host to inventory
|
||||
add_host:
|
||||
name: target_node
|
||||
ansible_host: "{{ target_host }}"
|
||||
ansible_user: "{{ target_user | default('root') }}"
|
||||
ansible_ssh_pass: "{{ target_password | default(omit) }}"
|
||||
ansible_ssh_private_key_file: "{{ target_private_key_file | default(omit) }}"
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
|
||||
- name: Bootstrap Node
|
||||
hosts: target_node
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- common
|
||||
29
ansible/playbooks/semaphore/configure_networking.yml
Normal file
29
ansible/playbooks/semaphore/configure_networking.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Register Target Host
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Verify target_host is defined
|
||||
fail:
|
||||
msg: "The 'target_host' variable must be defined (e.g. 192.168.1.10)"
|
||||
when: target_host is not defined
|
||||
|
||||
- name: Add target host to inventory
|
||||
add_host:
|
||||
name: target_node
|
||||
ansible_host: "{{ target_host }}"
|
||||
ansible_user: "{{ target_user | default('root') }}"
|
||||
ansible_ssh_pass: "{{ target_password | default(omit) }}"
|
||||
ansible_ssh_private_key_file: "{{ target_private_key_file | default(omit) }}"
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
|
||||
- name: Configure Networking
|
||||
hosts: target_node
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Run networking task from common role
|
||||
include_role:
|
||||
name: common
|
||||
tasks_from: networking.yml
|
||||
29
ansible/playbooks/semaphore/configure_users.yml
Normal file
29
ansible/playbooks/semaphore/configure_users.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Register Target Host
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Verify target_host is defined
|
||||
fail:
|
||||
msg: "The 'target_host' variable must be defined (e.g. 192.168.1.10)"
|
||||
when: target_host is not defined
|
||||
|
||||
- name: Add target host to inventory
|
||||
add_host:
|
||||
name: target_node
|
||||
ansible_host: "{{ target_host }}"
|
||||
ansible_user: "{{ target_user | default('root') }}"
|
||||
ansible_ssh_pass: "{{ target_password | default(omit) }}"
|
||||
ansible_ssh_private_key_file: "{{ target_private_key_file | default(omit) }}"
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
|
||||
- name: Configure Users
|
||||
hosts: target_node
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Run users task from common role
|
||||
include_role:
|
||||
name: common
|
||||
tasks_from: users.yml
|
||||
34
ansible/playbooks/semaphore/manage_proxmox.yml
Normal file
34
ansible/playbooks/semaphore/manage_proxmox.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
- name: Register Proxmox Host
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Verify proxmox_host is defined
|
||||
fail:
|
||||
msg: "The 'proxmox_host' variable must be defined."
|
||||
when: proxmox_host is not defined
|
||||
|
||||
- name: Verify proxmox_action is defined
|
||||
fail:
|
||||
msg: "The 'proxmox_action' variable must be defined (e.g. create_vm, create_template, delete_vm)."
|
||||
when: proxmox_action is not defined
|
||||
|
||||
- name: Add Proxmox host to inventory
|
||||
add_host:
|
||||
name: proxmox_node
|
||||
ansible_host: "{{ proxmox_host }}"
|
||||
ansible_user: "{{ proxmox_user | default('root') }}"
|
||||
ansible_ssh_pass: "{{ proxmox_password | default(omit) }}"
|
||||
ansible_ssh_private_key_file: "{{ proxmox_private_key_file | default(omit) }}"
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
|
||||
- name: Execute Proxmox Action
|
||||
hosts: proxmox_node
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
vars:
|
||||
# Explicitly map the action variable if needed, though role should pick it up from host vars or extra vars
|
||||
proxmox_action: "{{ proxmox_action }}"
|
||||
roles:
|
||||
- proxmox_vm
|
||||
Reference in New Issue
Block a user