refactor ♻️: Improve formatting and consistency in setupacdc.yml
Refactored the setupacdc.yml file to improve formatting, consistency, and readability. This includes standardizing indentation, spacing, and variable naming conventions.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
- hosts: "{{ dest_hosts }}"
|
- hosts: '{{ dest_hosts }}'
|
||||||
gather_facts: yes
|
gather_facts: yes
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
- name: Show Details for Each Interface (Excluding Loopback)
|
- name: Show Details for Each Interface (Excluding Loopback)
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: hostvars['localhost']['ansible_' + item]
|
var: hostvars['localhost']['ansible_' + item]
|
||||||
loop: "{{ ansible_interfaces }}"
|
loop: '{{ ansible_interfaces }}'
|
||||||
when: hostvars['localhost']['ansible_' + item] is defined and item not in ['lo']
|
when: hostvars['localhost']['ansible_' + item] is defined and item not in ['lo']
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -6,26 +6,26 @@
|
|||||||
become_user: root
|
become_user: root
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
|
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
|
||||||
mac_address: "8E:90:31:DE:31:36"
|
mac_address: '8E:90:31:DE:31:36'
|
||||||
|
|
||||||
container_id: 200
|
container_id: 200
|
||||||
container_template: "/var/lib/vz/template/cache/debian-13-standard_13.1-1_amd64.tar.zst"
|
container_template: '/var/lib/vz/template/cache/debian-13-standard_13.1-1_amd64.tar.zst'
|
||||||
container_ostype: debian
|
container_ostype: debian
|
||||||
container_hostname: "{{ addc_hostname }}"
|
container_hostname: '{{ addc_hostname }}'
|
||||||
container_password: "{{ addc_admin_password }}"
|
container_password: '{{ addc_admin_password }}'
|
||||||
container_storage: local-lvm
|
container_storage: local-lvm
|
||||||
container_rootfs_size: 8G
|
container_rootfs_size: 8G
|
||||||
container_memory: 1024
|
container_memory: 1024
|
||||||
container_swap: 256
|
container_swap: 256
|
||||||
container_cores: 2
|
container_cores: 2
|
||||||
container_net: name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }},hwaddr={{ mac_address }}
|
container_net: name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }},hwaddr={{ mac_address }}
|
||||||
container_features: "keyctl=1,nesting=1,mount=cifs"
|
container_features: 'keyctl=1,nesting=1,mount=cifs'
|
||||||
container_description: default lxc
|
container_description: default lxc
|
||||||
container_onboot: 1
|
container_onboot: 1
|
||||||
container_protection: 0
|
container_protection: 0
|
||||||
container_unprivileged: 1
|
container_unprivileged: 1
|
||||||
container_pubkey: "{{ ssh_public_keys[0] }}"
|
container_pubkey: '{{ ssh_public_keys[0] }}'
|
||||||
container_tags:
|
container_tags:
|
||||||
- ansible_managed
|
- ansible_managed
|
||||||
- test
|
- test
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
- name: Combine SSH public keys into one file
|
- name: Combine SSH public keys into one file
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: "{{ ssh_keys_file }}"
|
dest: '{{ ssh_keys_file }}'
|
||||||
content: |
|
content: |
|
||||||
{% for key in ssh_public_keys %}
|
{% for key in ssh_public_keys %}
|
||||||
{{ key }}
|
{{ key }}
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
- name: debug
|
- name: debug
|
||||||
# Comment
|
# Comment
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Hello world! {{ container_password }}"
|
msg: 'Hello world! {{ container_password }}'
|
||||||
verbosity: 0
|
verbosity: 0
|
||||||
|
|
||||||
|
|
||||||
@@ -54,21 +54,21 @@
|
|||||||
pct create {{ container_id }} {{ container_template }} \
|
pct create {{ container_id }} {{ container_template }} \
|
||||||
-ostype {{ container_ostype }} \
|
-ostype {{ container_ostype }} \
|
||||||
-hostname {{ container_hostname }} \
|
-hostname {{ container_hostname }} \
|
||||||
-password "{{ container_password }}" \
|
-password '{{ container_password }}' \
|
||||||
-ssh-public-keys "{{ ssh_keys_file }}" \
|
-ssh-public-keys '{{ ssh_keys_file }}' \
|
||||||
-cores {{ container_cores }} \
|
-cores {{ container_cores }} \
|
||||||
-memory {{ container_memory }} \
|
-memory {{ container_memory }} \
|
||||||
-swap {{ container_swap }} \
|
-swap {{ container_swap }} \
|
||||||
-net0 "{{container_net}}" \
|
-net0 '{{container_net}}' \
|
||||||
-storage {{ container_storage }} \
|
-storage {{ container_storage }} \
|
||||||
-description "{{ container_description }}" \
|
-description '{{ container_description }}' \
|
||||||
-onboot {{ container_onboot }} \
|
-onboot {{ container_onboot }} \
|
||||||
-protection {{ container_protection }} \
|
-protection {{ container_protection }} \
|
||||||
-unprivileged {{ container_unprivileged }} \
|
-unprivileged {{ container_unprivileged }} \
|
||||||
-tags "{{ container_tags | join(',') }}" \
|
-tags '{{ container_tags | join(',') }}' \
|
||||||
-features "{{ container_features }}"
|
-features '{{ container_features }}'
|
||||||
args:
|
args:
|
||||||
creates: "/etc/pve/lxc/{{ container_id }}.conf"
|
creates: '/etc/pve/lxc/{{ container_id }}.conf'
|
||||||
no_log: false
|
no_log: false
|
||||||
# -password {{ container_password }} \
|
# -password {{ container_password }} \
|
||||||
# -rootfs {{ container_storage }}:{{ container_id }}/vm-{{ container_id }}-disk-0.raw,size=7G \
|
# -rootfs {{ container_storage }}:{{ container_id }}/vm-{{ container_id }}-disk-0.raw,size=7G \
|
||||||
@@ -91,15 +91,15 @@
|
|||||||
- name: Wait until container has an IP address
|
- name: Wait until container has an IP address
|
||||||
ansible.builtin.shell: "pct exec {{ container_id }} -- hostname -I | awk '{print $1}'"
|
ansible.builtin.shell: "pct exec {{ container_id }} -- hostname -I | awk '{print $1}'"
|
||||||
register: lxc_ip
|
register: lxc_ip
|
||||||
until: lxc_ip.stdout != ""
|
until: lxc_ip.stdout != ''
|
||||||
retries: 10
|
retries: 10
|
||||||
delay: 5
|
delay: 5
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: lxc_ip.stdout == ""
|
failed_when: lxc_ip.stdout == ''
|
||||||
|
|
||||||
- name: Wait for SSH to become available
|
- name: Wait for SSH to become available
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
host: "{{ lxc_ip.stdout }}"
|
host: '{{ lxc_ip.stdout }}'
|
||||||
port: 22
|
port: 22
|
||||||
delay: 5
|
delay: 5
|
||||||
timeout: 60
|
timeout: 60
|
||||||
@@ -115,16 +115,16 @@
|
|||||||
become: true
|
become: true
|
||||||
|
|
||||||
# vars:
|
# vars:
|
||||||
# addc_admin_password: "{{ addc_adminpass }}"
|
# addc_admin_password: '{{ addc_adminpass }}'
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
# - name: Ensure SSH authorized keys are present
|
# - name: Ensure SSH authorized keys are present
|
||||||
# ansible.posix.authorized_key:
|
# ansible.posix.authorized_key:
|
||||||
# user: root
|
# user: root
|
||||||
# key: "{{ item }}"
|
# key: '{{ item }}'
|
||||||
# state: present
|
# state: present
|
||||||
# loop: "{{ ssh_public_keys }}"
|
# loop: '{{ ssh_public_keys }}'
|
||||||
|
|
||||||
- name: Install useful packages
|
- name: Install useful packages
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
|
|
||||||
- name: Update all packages, autoclean, and autoremove
|
- name: Update all packages, autoclean, and autoremove
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "*"
|
name: '*'
|
||||||
state: latest
|
state: latest
|
||||||
autoclean: yes
|
autoclean: yes
|
||||||
autoremove: yes
|
autoremove: yes
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
|
|
||||||
- name: Set timezone to {{ localization_timezone }}
|
- name: Set timezone to {{ localization_timezone }}
|
||||||
community.general.timezone:
|
community.general.timezone:
|
||||||
name: "{{ localization_timezone }}"
|
name: '{{ localization_timezone }}'
|
||||||
notify: Restart sshd
|
notify: Restart sshd
|
||||||
tags: [timezone]
|
tags: [timezone]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user