diff --git a/roles/kv/tasks/main.yml b/roles/kv/tasks/main.yml index 4897e20..5c0bb9e 100644 --- a/roles/kv/tasks/main.yml +++ b/roles/kv/tasks/main.yml @@ -14,42 +14,26 @@ loop: - curl - jq -- name: Fetch the Kube-VIP version - ansible.builtin.shell: - cmd: >- - curl -sL https://api.github.com/repos/kube-vip/kube-vip/releases | jq -r ".[0].name" - register: init_kvv -- name: Output registered value - ansible.builtin.debug: - var: init_kvv.stdout -- name: Check if alias is already defined - ansible.builtin.lineinfile: - state: absent - path: "/root/.bashrc" - regexp: "^alias\ kube-vip=" - check_mode: true - changed_when: false # This just makes things look prettier in the logs - register: check -- name: Add an alias to bash rc files. - ansible.builtin.lineinfile: - state: present - path: /root/.bashrc - line: >- - alias kube-vip="ctr image pull ghcr.io/kube-vip/kube-vip:$KVVERSION; ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:$KVVERSION vip /kube-vip" - environment: - KVVERSION: "{{ init_kvv.stdout }}" - when: check.found == 0 +- name: Update the bash rc file + ansible.builtin.template: + src: bashrc.j2 + dest: /root/.bashrc + owner: root + group: root + mode: ug+rw,o-rwx - name: Deploy the manifest ansible.builtin.shell: cmd: |- + source /root/.bashrc + kube-vip kube-vip manifest pod \ - --interface $INTERFACE \ - --address $VIP \ + --interface "{{ kv_interface }}" \ + --address "{{ kv_aa }}" \ --controlplane \ --services \ --arp \ --leaderElection | tee /etc/kubernetes/manifests/kube-vip.yaml - environment: - INTERFACE: "{{ kv_interface }}" - KVVERSION: "{{ init_kvv.stdout }}" - VIP: "{{ kv_aa }}" + register: kv_manifest +- name: Output kube-vip + ansible.builtin.debug: + var: kv_manifest diff --git a/roles/kv/templates/bashrc.j2 b/roles/kv/templates/bashrc.j2 new file mode 100644 index 0000000..132794f --- /dev/null +++ b/roles/kv/templates/bashrc.j2 @@ -0,0 +1,62 @@ +#!/bin/bash + +CLICOLOR=1 +INTERFACE=enp0s20f0u4 +KVVERSION=$(curl -sL https://api.github.com/repos/kube-vip/kube-vip/releases | jq -r ".[0].name") +# shellcheck disable=SC2016 +LESS='-R --use-color -Dd+r$Du+b$' +LSCOLORS="Ea" +PS1='[\[\e[38;5;196;1m\]\u\[\e[0m\]@\[\e[38;5;213;1m\]\H\[\e[0m\]:\w]{$?}\$ ' +PATH="$PATH:/root/.local/bin" +VIP=192.168.5.30 + +# shellcheck disable=SC1091 +if [ -f /usr/share/bash-completion/bash_completion ]; then + source /usr/share/bash-completion/bash_completion +fi + +export CLICOLOR +export INTERFACE +export KVVERSION +export LESS +export LSCOLORS +export PATH +export PS1 +export VIP + + +if [ ! -f "$HOME/.vim/autoload/plug.vim" ]; then + if [ -f /usr/bin/pacman ]; then + if [ ! -f /usr/bin/node ]; then + pacman -S npm + fi + if [ ! -f /usr/bin/xsel ]; then + pacman -Sy --noconfirm xsel + fi + + if [ -f /usr/bin/xsel ]; then + alias pbcopy='xsel --clipboard --input' + alias pbpaste='xsel --clipboard --output' + fi + fi + if [ -f /usr/bin/apt-get ]; then + sudo apt-get -y update + sudo apt-get -y install curl git npm + fi + git clone git@github.com:bryant/neovim.git "$HOME/Documents/src/github.com/bryant/neovim" + curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + vim +PlugInstall +qall +fi + +eval "$(direnv hook bash)" + +alias diff='diff --color=auto' +alias grep='grep --color=auto' +alias h='helm' +alias ip='ip -color=auto' +alias k='kubectl' +# shellcheck disable=SC2139 +alias kube-vip="ctr image pull ghcr.io/kube-vip/kube-vip:${KVVERSION}; ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:${KVVERSION} vip /kube-vip" +alias ls='ls --color' + diff --git a/site.yml b/site.yml index 64cde55..3a8daf7 100644 --- a/site.yml +++ b/site.yml @@ -30,7 +30,7 @@ tags: - join - name: Kube VIP - hosts: kcp + hosts: kcp01_init become: true roles: - role: kv