Skip to content

Commit

Permalink
ansible: Move group vars to specific directory
Browse files Browse the repository at this point in the history
Move the group variables from `hosts.yaml` to a specific `group_vars`
directory, keeping the `hosts.yaml` file clean and simple.

Moreover, this keeps the host definition from their configuration
separate, making the project more maintainable.

Signed-off-by: Dimitris Poulopoulos <[email protected]>
  • Loading branch information
dpoulopoulos committed Mar 19, 2024
1 parent 1e7ce06 commit c6eeb74
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
35 changes: 35 additions & 0 deletions ansible/inventory/group_vars/all/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# Ansible will SSH into managed machines as this user
ansible_user: root

# Local user on the control machine
user: dimpo

# Home directory of the local user
home: /home/{{ user }}

# Name of the Python virtual environment
virtualenv: kubeflow-on-kvm

# Path to the Ansible Python interpreter
python_interpreter: |
"{{ home }}/.pyenv/versions/{{ virtualenv }}/bin/python"
# Password for the root user on the managed machines
rootpw_hash: |
$6$QDiGMXBTKPwTglrM$JJ4yRe4mw.SgPWVIOb/E/SYN5wQlRatEFR96NkHTqoBco334jh1pmulQ.Y64EAKc7KVNvepKdzWTjp5NxzjGz1
# SSH key for the root user on the managed machines
ssh_key: "{{ lookup('file', '/home/{{ user }}/.ssh/id_rsa.pub') }}"

# Name of the VM host
vm_host: boogie

# Name of the PXE server
pxe_server: pxe-server

# Network configuration for the PXE server
dhcp_network: 192.168.122.0
dhcp_gateway: 192.168.122.1
dhcp_netmask: 255.255.255.0
dhcp_nameserver: 192.168.122.1
5 changes: 5 additions & 0 deletions ansible/inventory/group_vars/libvirt/libvirt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# libvirt VM hardware defaults
vm_vcpus: 4
vm_ram_mb: 16384
vm_disk_gb: 64
29 changes: 1 addition & 28 deletions ansible/inventory/hosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,21 @@ all:
hosts:
boogie:
ansible_connection: local
ansible_python_interpreter: /home/dimpo/.pyenv/versions/kubeflow-on-kvm/bin/python
ansible_python_interpreter: "{{ python_interpreter }}"
pxe-server:
ipv4: 192.168.122.28
dhcp_network: 192.168.122.0
dhcp_gateway: 192.168.122.1
dhcp_netmask: 255.255.255.0
dhcp_nameserver: 192.168.122.1
k8s-dev1-ctrl:
ipv4: 192.168.122.128
k8s-dev1-worker1:
ipv4: 192.168.122.129
k8s-dev1-worker2:
ipv4: 192.168.122.130
vars:
# Ansible will SSH into managed machines as this user
ansible_user: root

# Local user on the control machine
user: dimpo

# Define the password for the root user on the managed machines
rootpw_hash: |
$6$QDiGMXBTKPwTglrM$JJ4yRe4mw.SgPWVIOb/E/SYN5wQlRatEFR96NkHTqoBco334jh1pmulQ.Y64EAKc7KVNvepKdzWTjp5NxzjGz1
# Define the SSH key for the root user on the managed machines
ssh_key: "{{ lookup('file', '/home/{{ user }}/.ssh/id_rsa.pub') }}"

vm_host: boogie
pxe_server: pxe-server
children:
libvirt:
hosts:
k8s-dev1-ctrl:
vm_vcpus: 4
vm_ram_mb: 16384
vm_disk_gb: 64
k8s-dev1-worker1:
k8s-dev1-worker2:
vars:
vm_vcpus: 8
vm_ram_mb: 32768
vm_disk_gb: 128
admin:
hosts:
boogie:
Expand Down

0 comments on commit c6eeb74

Please sign in to comment.