generated from edwardtheharris/ansible-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
- name: Ensure manifests directory | ||
ansible.builtin.file: | ||
state: directory | ||
recurse: true | ||
dest: /etc/kubernetes/manifests | ||
owner: kube | ||
group: kube | ||
mode: ug+rw,o+r | ||
- name: Install prerequisites for creating the manifest | ||
community.general.pacman: | ||
name: "{{ item }}" | ||
state: present | ||
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: Deploy the manifest | ||
ansible.builtin.shell: | ||
cmd: |- | ||
kube-vip manifest pod \ | ||
--interface $INTERFACE \ | ||
--address $VIP \ | ||
--controlplane \ | ||
--services \ | ||
--arp \ | ||
--leaderElection | tee /etc/kubernetes/manifests/kube-vip.yaml | ||
environment: | ||
INTERFACE: "{{ kv_interface }}" | ||
KVVERSION: "{{ init_kvv.stdout }}" | ||
VIP: "{{ kv_aa }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,10 @@ | |
- role: join | ||
tags: | ||
- join | ||
- name: Kube VIP | ||
hosts: kcp | ||
become: true | ||
roles: | ||
- role: kv | ||
tags: | ||
- kv |