πŸ–₯️ Configuring an Ansible Control Node

The following steps describe how to configure an Ansible control node. These steps have been automated using the Ansible deployment playbook.


πŸ’½ Adding a Second Drive

  1. Add a new disk from the Proxmox web GUI.
  2. Boot the VM.
  3. Enumerate the new disk using fdisk -l.
  4. Use fdisk to create a new partition.
  5. Format the new partition (e.g., sudo mkfs -t ext4 /dev/vdb1).
  6. Create the mount point /ansible (e.g., sudo mkdir /ansible).
  7. Add the new mount point to /etc/fstab (e.g.,
    /dev/vdb1 /ansible ext4 defaults 0 2).
  8. Mount the disk (e.g., sudo mount /ansible).
  9. Grant full group access:
    sudo chmod -R g+rwx /ansible.

🏒 Joining the Machine to Active Directory

See the guide:
[Looks like the result wasn't safe to show. Let's switch things up and try something else!]


πŸ” Configure the Ansible Become User

Use a non‑root user for privilege escalation. The Active Directory user ansible@refol.us will serve as the Ansible become user.

Create the Ansible Active Directory User

New-ADUser -Name "Ansible" -GivenName "Ansible" -Surname "User" -SamAccountName "ansible" -UserPrincipalName "ansible@refol.us" -AccountPassword(Read-Host -AsSecureString "Input Password") -Enabled $true

Enter a password when prompted.

Grant Proxmox Permissions to the ansible User

In Proxmox:

Datacenter β†’ Permissions β†’ Users β†’ Add
Add the user ansible.

❗IMPORTANT The Active Directory domain refol.us must be added as a Realm before adding the user.
Navigate to Datacenter β†’ Permissions β†’ Realms β†’ Add β†’ Active Directory Server.

Create a Proxmox API Token

This token will be used by Ansible for API calls.

Datacenter β†’ Permissions β†’ API Tokens β†’ Add

Click Add, then copy the Token ID and Secret.

Create the ansible Group

sudo addgroup ansible

Add ansible@refol.us to the ansible Group

sudo usermod -a -G ansible ansible@refol.us
sudo usermod -a -G ansible ansible

Add ansible@refol.us to the sudo Group

sudo usermod -a -G sudo ansible@refol.us
sudo usermod -a -G sudo ansible

Configure Ansible Become Settings

become: true
become_user: ansible
become_method: sudo

πŸ“¦ Ansible Installation

As of this writing, the latest version is Ansible 10.4.0, which includes ansible-core 2.17.4.

Install Python

sudo apt-get update
sudo apt-get install python3

Create a Python Virtual Environment

A virtual environment allows multiple Ansible versions to coexist.

Install the venv Module

sudo apt-get update
sudo apt-get install python3.12-venv

Create and Activate the Virtual Environment

cd /ansible
python3 -m venv python3.12.3_ansible10.4.0
source python3.12.3_ansible10.4.0/bin/activate

Deactivate with:

deactivate

Upgrade pip

pip install --upgrade pip setuptools

Install Ansible

pip install ansible

Verify installation:

ansible --version

(Version output omitted for brevity.)


πŸ“š Install Python Modules

proxmoxer

python -m pip install proxmoxer

requests

python -m pip install requests

pycdlib

python -m pip install pycdlib

Other Required Packages

sudo apt install sshpass acl

πŸš€ Getting Started with Ansible

Activate the Working Environment

cd /ansible/dev
source ../python3.12.3_ansible10.4.0/bin/activate

Create ansible.cfg

ansible-config init --disabled -t all > ansible.cfg

Configure the Vault Password File

Create ~/.vault_pass.txt and add your vault password.

In ansible.cfg:

vault_password_file=~/.vault_pass.txt

πŸ”‘ Configure SSH Access to Proxmox Servers

Ensure the Ansible account can SSH into each Proxmox node:

ssh pve-0
ssh pve-1
ssh pve-2

Ensure the become user can also connect:

ssh ansible@pve-0
ssh ansible@pve-1
ssh ansible@pve-2

Test connectivity:

ansible pvenodes -i inventory/pve/inventory.ini -m ping --user=ansible -k

Enter the password when prompted.


🧹 Ansible Lint

pip3 install ansible-lint

πŸ“– References