Skip to content

Commit

Permalink
Update template, role
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
edwardtheharris committed Jul 25, 2024
1 parent 21837cf commit 4f3b794
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 32 deletions.
46 changes: 15 additions & 31 deletions roles/kv/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
62 changes: 62 additions & 0 deletions roles/kv/templates/bashrc.j2
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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'

2 changes: 1 addition & 1 deletion site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
tags:
- join
- name: Kube VIP
hosts: kcp
hosts: kcp01_init
become: true
roles:
- role: kv
Expand Down

0 comments on commit 4f3b794

Please sign in to comment.