# IPVO workshop setup ## Directory Structure ```shell tree ~/Desktop/ipvo_workshop/ /home/antonio/Desktop/ipvo_workshop/ ├── ansible.cfg ├── inventory └── playbook.yml ``` ## Ansible project directory `ipvo_workshop` `playbook.yml` ```yaml - name: prepare environment for IPVO workshop hosts: localhost # you have to change this value into "all" become: true vars: packages: - code - vim - nano - docker - yay user: antonio # you have to change this user into "korisnik" tasks: - name: installed required packages pacman: name: "{{ item }}" state: latest loop: "{{ packages }}" - name: started docker service service: name: docker enabled: true state: started - name: added user to docker group user: name: "{{ user }}" groups: docker - name: installed k3s cluster shell: "curl -sfL https://get.k3s.io | sh -" - name: created ~/.kube/ directory file: path: "/home/{{ user }}/.kube/" mode: 0755 owner: "{{ user }}" group: "{{ user }}" state: directory - name: permissions for /etc/rancher/k3s/k3s.yaml file: path: /etc/rancher/k3s/k3s.yaml mode: 0755 - name: copied k3s kube config to our ~/.kube/config copy: src: /etc/rancher/k3s/k3s.yaml dest: "/home/{{ user }}/.kube/config" mode: 0755 owner: "{{ user }}" group: "{{ user }}" - name: test if k3s is installed command: "kubectl get nodes" register: output - name: print stdout of previous command debug: var: "output.stdout_lines" - name: install openlens-bin hosts: localhost # change value into "all" become: false tasks: - name : Install openlens using yay with automatic selection shell: "sudo yes | yay -S openlens-bin" - name: reboot hosts: localhost # change value into "all" become: true tasks: - name: reboot system reboot: ``` `ansible.cfg` ```yaml [defaults] inventory = inventory remote_user = antonio ask_pass = false [privilege_escalation] become = true become_method = sudo become_user = root become_ask_pass = false ``` > setup values recording to 350 classroom `inventory` ```shell <350-inventory-file> ``` ## How to run `ansible-playbook playbook.yml` ## Please test openlens Try to run software called `openlens` on managed nodes. ## Expected output from `playbook.yml` ```shell PLAY [prepare environment for IPVO workshop] *************************************************************************************************************** TASK [Gathering Facts] ************************************************************************************************************************************* ok: [localhost] TASK [installed required packages] ************************************************************************************************************************* ok: [localhost] => (item=code) ok: [localhost] => (item=vim) ok: [localhost] => (item=nano) ok: [localhost] => (item=docker) TASK [started docker service] ****************************************************************************************************************************** ok: [localhost] TASK [added user to docker group] ************************************************************************************************************************** ok: [localhost] TASK [installed k3s cluster] ******************************************************************************************************************************* changed: [localhost] TASK [created ~/.kube/ directory] ************************************************************************************************************************** ok: [localhost] TASK [permissions for /etc/rancher/k3s/k3s.yaml] *********************************************************************************************************** ok: [localhost] TASK [copied k3s kube config to our ~/.kube/config] ******************************************************************************************************** ok: [localhost] TASK [test if k3s is installed] **************************************************************************************************************************** changed: [localhost] TASK [print stdout of previous command] ******************************************************************************************************************** ok: [localhost] => { "output.stdout_lines": [ "NAME STATUS ROLES AGE VERSION", "lab-test Ready control-plane,master 30m v1.28.5+k3s1" ] } ```