77 lines
2.3 KiB
YAML
77 lines
2.3 KiB
YAML
---
|
|
- name: Deploy LXC
|
|
hosts: all
|
|
remote_user: ansible
|
|
gather_facts: false
|
|
|
|
vars_files:
|
|
../inventory/group_vars/all/secrets.yaml
|
|
vars:
|
|
ansible_user_passwd_hash: "{{ ansible_password | password_hash('sha512', 's3edscrj45e6r') }}"
|
|
user_passwd_hash: "{{ user_password | password_hash('sha512', 's3ed6123jhgcr') }}"
|
|
|
|
vars_prompt:
|
|
- name: lxc_hostname
|
|
prompt: "Hostname for the container (may only contain letters (a-z, A-Z), numbers (0-9), and hyphens)"
|
|
private: false
|
|
|
|
- name: lxc_root_password
|
|
prompt: "Root password"
|
|
private: true
|
|
confirm: true
|
|
encrypt: sha512_crypt
|
|
|
|
- name: lxc_ip_address
|
|
prompt: "IP address for the container (in x.x.x.x/x formant)"
|
|
private: false
|
|
|
|
pre_tasks:
|
|
- name: Validate hostname
|
|
ansible.builtin.fail:
|
|
msg: |
|
|
Invalid hostname: "{{ lxc_hostname }}"
|
|
Hostname may only contain letters (a-z, A-Z), numbers (0-9), and hyphens (-).
|
|
when: not lxc_hostname is regex('^[a-zA-Z0-9-]+$')
|
|
run_once: true
|
|
|
|
roles:
|
|
- ../roles/deploy_lxc_on_proxmox
|
|
|
|
tasks:
|
|
- name: Make the prompted hostname available to the whole playbook
|
|
ansible.builtin.set_fact:
|
|
fact_lxc_hostname: "{{ lxc_hostname }}"
|
|
|
|
- name: Make the prompted IP available to the whole playbook
|
|
ansible.builtin.set_fact:
|
|
#fact_lxc_ip_address: "{{ lxc_ip_address | ansible.utils.ipaddr('address') }}"
|
|
fact_lxc_ip_address: "{{ lxc_ip_address.split('/') | first }}"
|
|
|
|
- name: Add the target host to the inventory
|
|
ansible.builtin.add_host:
|
|
name: "{{ fact_lxc_ip_address }}"
|
|
groups: new_host
|
|
ansible_user: ansible
|
|
ansible_become_password: "{{ ansible_become_passwd }}"
|
|
|
|
|
|
- name: Configure LXC
|
|
hosts: new_host
|
|
remote_user: ansible
|
|
|
|
vars_files:
|
|
../inventory/group_vars/all/secrets.yaml
|
|
vars:
|
|
ansible_user_passwd_hash: "{{ ansible_password | password_hash('sha512', 's3edscrj45e6r') }}"
|
|
user_passwd_hash: "{{ user_password | password_hash('sha512', 's3ed6123jhgcr') }}"
|
|
|
|
roles:
|
|
- ../roles/configure_ansible_user
|
|
- ../roles/harden_ssh
|
|
- ../roles/base_system
|
|
- ../roles/human_admin_user
|
|
- ../roles/set_locale_and_time
|
|
# Update configs - omz, nvim, ranger and so on. Distribute the last version of those configs
|
|
- ../roles/update_configs
|
|
|