Advertisement
Guest User

Untitled

a guest
Mar 31st, 2023
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.31 KB | None | 0 0
  1. ---
  2. - hosts: k3s_cluster
  3.   gather_facts: yes
  4.   become: true
  5.  
  6.   tasks:
  7.     ## UNTESTED!!!!!!!!!!!!!
  8.  
  9.     - name: Disable SWAP since kubernetes can't work with swap enabled (1/2)
  10.       shell: |
  11.        swapoff -a
  12.       when: kubernetes_installed is changed
  13.  
  14.     ## UNTESTED!!!!!!!!!!!!!
  15.  
  16.     - name: Disable SWAP in fstab since kubernetes can't work with swap enabled (2/2)
  17.       replace:
  18.         path: /etc/fstab
  19.         regexp: '^([^#].*?\sswap\s+sw\s+.*)$'
  20.         replace: '# \1'
  21.       when: kubernetes_installed is changed
  22.  
  23.     - name: Check if rancher dir exists
  24.       stat:
  25.         path: /etc/rancher
  26.       register: stat_result
  27.  
  28.     - ansible.builtin.fail:
  29.         msg: k3s is already installed
  30.       when: stat_result.stat.exists
  31.  
  32.     - name: disable iv6 -> net.ipv6.conf.all.disable_ipv6=1
  33.       ansible.posix.sysctl:
  34.         name: "net.ipv6.conf.all.disable_ipv6"
  35.         value: "1"
  36.         state: present
  37.         sysctl_set: true
  38.         reload: true
  39.       when: disable_ipv6
  40.  
  41.     - name: disable iv6 -> net.ipv6.conf.default.disable_ipv6=1
  42.       ansible.posix.sysctl:
  43.         name: "net.ipv6.conf.default.disable_ipv6"
  44.         value: "1"
  45.         state: present
  46.         sysctl_set: true
  47.         reload: true
  48.       when: disable_ipv6
  49.  
  50.     - name: disable iv6 -> net.ipv6.conf.lo.disable_ipv6=1
  51.       ansible.posix.sysctl:
  52.         name: "net.ipv6.conf.lo.disable_ipv6"
  53.         value: "1"
  54.         state: present
  55.         sysctl_set: true
  56.         reload: true
  57.       when: disable_ipv6
  58.  
  59.     - name: wait until apt (cloud init) finished
  60.       shell: |
  61.        while ! pgrep apt ; (($?)) ;do
  62.             sleep 10
  63.         done
  64.       args:
  65.         executable: /bin/bash
  66.  
  67.     - name: apt-get dist-upgrade
  68.       ansible.builtin.apt:
  69.         upgrade: dist
  70.         update_cache: yes
  71.  
  72.     - name: install nfs-common
  73.       ansible.builtin.package:
  74.         name: nfs-common
  75.         state: present
  76.  
  77.     - name: install locales-all
  78.       ansible.builtin.package:
  79.         name: locales-all
  80.         state: present
  81.  
  82.     - name: ensuere LANG=C.UTF-8 (24h format)
  83.       shell: update-locale LANG=C.UTF-8
  84.       args:
  85.         executable: /bin/bash
  86.  
  87.     # we need a faster way after proxmox rollbacks
  88.     # sudo htpdate -a google.com
  89.     - name: install htpdate
  90.       ansible.builtin.package:
  91.         name: htpdate
  92.         state: present
  93.  
  94.     - name: install ntp
  95.       ansible.builtin.package:
  96.         name: ntp
  97.         state: present
  98.  
  99.     - name: enable service ntp and ensure it is not masked
  100.       ansible.builtin.systemd:
  101.         name: ntp
  102.         enabled: true
  103.         masked: no
  104.  
  105.     - name: start ntpd
  106.       ansible.builtin.systemd:
  107.         state: started
  108.         name: ntp
  109.  
  110. # we need this to enable the agent -  https://www.snel.com/support/nstall-qemu-guest-agent-for-debian-ubuntu/
  111. # qm create --agent=1 # https://pve.proxmox.com/pve-docs/qm.1.html
  112.  
  113.     - name: install qemu-guest-agent
  114.       ansible.builtin.package:
  115.         name: qemu-guest-agent
  116.         state: present
  117.  
  118.     - name: enable service qemu-guest-agent and ensure it is not masked
  119.       ansible.builtin.systemd:
  120.         name: qemu-guest-agent
  121.         enabled: true
  122.         masked: no
  123.  
  124.     - name: start qemu-guest-agent
  125.       ansible.builtin.systemd:
  126.         state: started
  127.         name: qemu-guest-agent
  128.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement