Skip to content
Snippets Groups Projects
user avatar
Flux authored
c394a99b
History

ansible-lab-hepto

Ansible repo to play with Hepto

Overview

After playbook run, it should be like :

/root/
├── env-mylab # source env-my lab before playing with cluster
├── hepto # Hepto source project if you asked to build it
├── manifests # sync a local folder to play with manifests
├── .bash_aliases # Some aliases to easily play with manifests or hepto

playbooks/hepto_node.yml will do :

  • Install new kernel (like 5.19) if var hepto_linux_kernel_pkgs: is uncommented (see inventory/sample/host_vars/mynode/hepto.yml)
  • Install go and other build dependencies if ansible-playbook ... -e hepto_build=true
  • build and cp hepto in /usr/local/bin if ansible-playbook ... -e hepto_build=true
  • modprobe each needed modules and add an entry to /etc/modules-load.d to persist during reboot
  • add to ~/.bash-aliases some dummy aliases (see roles/tedomum.hepto/defaults/main.yml var hepto_install_bash_aliases)
  • generate an env file env-mylab to be sourced source env-mylab if you use default aliases

Full node example

git clone https://forge.tedomum.net/tedomum/ansible-hepto.git mylab
cd mylab
cp inventory/sample inventory/mylab # Edit suit to your needs
ansible-galaxy install -r requirements.yml

See and adapt inventory/*/hosts, inventory/*/host_vars
Then

# Ask to build hepto if needed
ansible-playbook -i inventory/mylab/hosts playbooks/hepto_node.yml -e hepto_build=true -K # -K ask for sudo pass on mynode
# or
ansible-playbook -i inventory/mylab/hosts playbooks/hepto_node.yml -K # To avoid build or rebuild

Then ssh to your node, and you can play with aliases command

reminec@mynode:~# sudo su
root@mynode:/home/reminec# cd /root
root@mynode:~# source env-mylab
root@mynode:~# h-start 
root@mynode:~# k get node
root@mynode:~# hepto info
root@mynode:~# k-create < manifests/sample/kube-proxy.yml

Example of aliases

root@mynode:~# cat ~/.bash_aliases 
alias k="hepto kubectl --cluster \$HEPTO_CLUSTER --name \$HEPTO_NODE --"
alias h-start="hepto start --cluster \$HEPTO_CLUSTER --name \$HEPTO_NODE --key \$HEPTO_KEY --iface \$HEPTO_IFACE --role \$HEPTO_ROLE"
alias k-create="hepto kubectl --cluster \$HEPTO_CLUSTER --name \$HEPTO_NODE -- create -f -"