diff --git a/inventory/localhost.yaml b/inventory/localhost.yaml new file mode 100644 index 0000000..b71186d --- /dev/null +++ b/inventory/localhost.yaml @@ -0,0 +1,7 @@ +--- +physical: + hosts: + localhost: + ansible_become_password: "{{ ansible_become_passwd }}" + ansible_connection: local + ansible_python_interpreter: "{{ ansible_playbook_python }}" diff --git a/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml b/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml index bd8d31a..a14f201 100644 --- a/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml +++ b/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml @@ -1,11 +1,30 @@ --- -- name: Deploy and set up an LXC container in Proxmox +- name: Physical machines maintanance play hosts: all remote_user: ansible - roles: - - ../roles/deploy_lxc_on_proxmox + 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:" + 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 + + + roles: + - ../roles/deploy_lxc_on_proxmox diff --git a/playbooks/maintain.yaml b/playbooks/maintain.yaml index aff6146..bd8d31a 100644 --- a/playbooks/maintain.yaml +++ b/playbooks/maintain.yaml @@ -1,29 +1,11 @@ --- -- name: Physical machines maintanance play +- name: Deploy and set up an LXC container in Proxmox hosts: all remote_user: ansible - + roles: + - ../roles/deploy_lxc_on_proxmox 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:" - 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 - - - roles: - - ../roles/deploy_lxc_on_proxmox diff --git a/requirements.txt b/requirements.txt index 1d11f18..bb5d472 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,10 +17,12 @@ mypy_extensions==1.1.0 packaging==26.2 pathspec==1.1.1 platformdirs==4.10.0 +proxmoxer>=2.3 pycparser==3.0 pytokens==0.4.1 PyYAML==6.0.3 referencing==0.37.0 +requests>=2.34.2 resolvelib==1.2.1 rpds-py==2026.6.3 ruamel.yaml==0.19.1 diff --git a/roles/deploy_lxc_on_proxmox/tasks/main.yaml b/roles/deploy_lxc_on_proxmox/tasks/main.yaml index 1a2bf10..f230a41 100644 --- a/roles/deploy_lxc_on_proxmox/tasks/main.yaml +++ b/roles/deploy_lxc_on_proxmox/tasks/main.yaml @@ -37,12 +37,11 @@ api_token_id: ansible api_token_secret: "{{ proxmox_token_secret }}" - vmid: 1040 + hostname: "{{ lxc_hostname }}" state: started - name: Sleep for a minute to ensure that ssh is ready become: false ansible.builtin.wait_for: timeout: 60 - delegate_to: localhost changed_when: false