mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-ansible-private.git
synced 2026-03-22 04:19:48 +00:00
Compare commits
96 Commits
kubernetes
...
a34e5a5e8b
| Author | SHA1 | Date | |
|---|---|---|---|
| a34e5a5e8b | |||
| 71ec9945b1 | |||
| 11dbff9b8a | |||
| fecbc54b79 | |||
| d693a947f2 | |||
| 8c882adffe | |||
| fff458af5a | |||
| de1925a486 | |||
| 2fdee619ca | |||
| 47411136d0 | |||
| 08a0bb3761 | |||
| 27b924b558 | |||
| d460624689 | |||
| 676cc04dd4 | |||
| e62baff9e7 | |||
| f532ff4507 | |||
| dd420b851c | |||
| 07698ad8a3 | |||
| b981b12635 | |||
| 5441e7852e | |||
| 5df04be859 | |||
| baa06e11d3 | |||
| 3afed3f5bd | |||
| 5d82af3236 | |||
| 946621ae59 | |||
| d6d5a94fd1 | |||
| d47040565a | |||
| a794dcd037 | |||
| fee0b08777 | |||
| d047d1da32 | |||
| 0d93657131 | |||
| 1b1d683d38 | |||
| 2bca89aa2d | |||
| e2450e477a | |||
| 4be17277b9 | |||
| f45445443f | |||
| 9e50c6c110 | |||
| 1e20c82f27 | |||
| adcbcca46c | |||
| 91355e6724 | |||
| 3d2d3278f3 | |||
| ab1769f830 | |||
| 91ded9edd2 | |||
| 460a1e07a3 | |||
| 5fab44c939 | |||
| 46994b5cc7 | |||
| 6dcc0640b6 | |||
| 20e6e518a4 | |||
| 99f42d7223 | |||
| d9d8a41574 | |||
| 2e3fe12b16 | |||
| bd480ae5cf | |||
| 564a9b028c | |||
| ae076fd98a | |||
| 5ce25f0267 | |||
| 5bb538322b | |||
| f34763271e | |||
| 1456906d65 | |||
| 87e269c4b0 | |||
| b172e24a0e | |||
| c850375dd4 | |||
| 9e7f5be196 | |||
| e64863f887 | |||
| c0a8b0b00a | |||
| 2b060b27f0 | |||
| 895dacd28d | |||
| d5ed666c77 | |||
| 6b864989f5 | |||
| b4b99298e7 | |||
| 077ac6f39b | |||
| 35a95c6553 | |||
| aa55c290e1 | |||
| e2c0cb640c | |||
| 6b0bbff17c | |||
| 7c2908bea6 | |||
| d79c611824 | |||
| b4ee6d1b83 | |||
| b774664389 | |||
| fd63bc9f0e | |||
| e8e9fa2d01 | |||
| 928c6b2445 | |||
| dc2f6b163c | |||
| 2f2d3c621b | |||
| e057170f9c | |||
| db1d69e566 | |||
| 138e0e5b8d | |||
| fe48f35c87 | |||
| e295c09152 | |||
| 814abb92dd | |||
| 983167e8bc | |||
| a142e3acda | |||
| 2eaea3dbb3 | |||
| db87c453ce | |||
| 5d60378c35 | |||
| 892b80c438 | |||
| 39dd5e0c72 |
@ -35,7 +35,7 @@ jobs:
|
||||
bw login --apikey
|
||||
echo "session"
|
||||
BW_SESSION=$(bw unlock "$BW_PASSWORD" --raw)
|
||||
|
||||
echo "BW_SESSION=$BW_SESSION" >> $GITEA_ENV
|
||||
|
||||
- name: Cloning ansible repository
|
||||
uses: actions/checkout@v4
|
||||
@ -55,4 +55,6 @@ jobs:
|
||||
- name: Run Ansible Playbook
|
||||
working-directory: ansible/iac
|
||||
run: |
|
||||
ansible-playbook -i inventory.ini playbook.yml
|
||||
ansible-playbook -i inventory.ini playbook.yml -e "BW_CLIENTID=$BW_CLIENTID BW_CLIENTSECRET=$BW_CLIENTSECRET BW_PASSWORD=$BW_PASSWORD BW_EMAIL=$BW_EMAIL"
|
||||
env:
|
||||
BW_SESSION: ${{ env.BW_SESSION }}
|
||||
@ -1,3 +1,9 @@
|
||||
# iac-ansible-private
|
||||
|
||||
iac-ansible-private
|
||||
iac-ansible-private
|
||||
|
||||
stolon comes from https://github.com/sorintlab/stolon/blob/master/examples/kubernetes/README.md
|
||||
qbittorrent comes from https://github.com/j4ym0/pia-qbittorrent-docker?tab=readme-ov-file
|
||||
prowlarr comes from https://docs.linuxserver.io/images/docker-prowlarr/#docker-mods
|
||||
and https://wiki.servarr.com/prowlarr/environment-variables
|
||||
|
||||
|
||||
10
playbook.yml
10
playbook.yml
@ -3,6 +3,7 @@
|
||||
become: yes
|
||||
roles:
|
||||
- common
|
||||
- vaultwarden
|
||||
- kubernetes
|
||||
- kube-master
|
||||
|
||||
@ -11,5 +12,14 @@
|
||||
become: yes
|
||||
roles:
|
||||
- common
|
||||
- vaultwarden
|
||||
- kubernetes
|
||||
- kube-node
|
||||
|
||||
- name: Configure Kubernetes Data
|
||||
hosts: master
|
||||
become: yes
|
||||
roles:
|
||||
- stolon
|
||||
- qbittorrent
|
||||
- prowlarr
|
||||
@ -22,7 +22,7 @@
|
||||
replace:
|
||||
path: /tmp/kube-flannel.yml
|
||||
regexp: '10\.244\.0\.0/16'
|
||||
replace: '10.244.0.0/16' # .3.
|
||||
replace: '10.240.0.0/16' # .3.
|
||||
|
||||
- name: Corrigir net-conf.json no manifest do Flannel
|
||||
become: true
|
||||
@ -55,8 +55,9 @@
|
||||
argv:
|
||||
- kubeadm
|
||||
- init
|
||||
- --pod-network-cidr=10.244.0.0/16 # .3.
|
||||
- --apiserver-advertise-address=192.168.1.150
|
||||
- --pod-network-cidr=10.240.0.0/16 # .3.
|
||||
- --apiserver-advertise-address=192.168.1.50
|
||||
- --service-cidr=10.95.0.0/16
|
||||
creates: /etc/kubernetes/admin.conf
|
||||
|
||||
|
||||
@ -102,6 +103,37 @@
|
||||
delay: 6
|
||||
become: yes
|
||||
|
||||
|
||||
- name: kubernetes untaint node-role.kubernetes.io/control-plane:NoSchedule
|
||||
become: true
|
||||
shell: |
|
||||
kubectl taint nodes --all node-role.kubernetes.io/control-plane:NoSchedule-
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
ignore_errors: yes
|
||||
|
||||
|
||||
- name: kubernetes unlabel node-role.kubernetes.io/control-plane
|
||||
become: true
|
||||
shell: |
|
||||
kubectl label nodes --all node-role.kubernetes.io/control-plane-
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
ignore_errors: yes
|
||||
|
||||
- name: kubernetes unlabel node.kubernetes.io/exclude-from-external-load-balancers
|
||||
become: true
|
||||
shell: |
|
||||
kubectl label nodes --all node.kubernetes.io/exclude-from-external-load-balancers-
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
ignore_errors: yes
|
||||
|
||||
|
||||
|
||||
- name: cat flannel
|
||||
become: true
|
||||
shell: |
|
||||
@ -133,6 +165,81 @@
|
||||
delay: 6
|
||||
become: yes
|
||||
|
||||
- name: Instalar Helm no nó master
|
||||
become: true
|
||||
shell: |
|
||||
curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
|
||||
args:
|
||||
creates: /usr/local/bin/helm
|
||||
|
||||
- name: Adicionar repositório Helm do CSI NFS
|
||||
command: >
|
||||
helm repo add csi-driver-nfs https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/charts
|
||||
args:
|
||||
creates: /root/.cache/helm/repository/csi-driver-nfs-index.yaml
|
||||
|
||||
- name: Atualizar repositórios Helm
|
||||
command: helm repo update
|
||||
|
||||
- name: Instalar CSI NFS Driver via Helm
|
||||
command: helm upgrade --install csi-driver-nfs csi-driver-nfs/csi-driver-nfs --namespace kube-system --version 4.12.0
|
||||
register: resultado_nfs
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
|
||||
|
||||
- name: Mostrar resultado do nfs csi driver
|
||||
debug:
|
||||
var: resultado_nfs.stdout_lines
|
||||
|
||||
|
||||
- name: Instalar MetalLB (manifest oficial)
|
||||
shell: kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.9/config/manifests/metallb-native.yaml
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
|
||||
- name: Esperar pelo webhook do MetalLB
|
||||
shell: kubectl get endpoints webhook-service -n metallb-system -o jsonpath='{.subsets[*].addresses[*].ip}'
|
||||
register: webhook_ready
|
||||
until: webhook_ready.stdout != ""
|
||||
retries: 10
|
||||
delay: 10
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
|
||||
- name: Criar IP pool
|
||||
shell: |
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: metallb.io/v1beta1
|
||||
kind: IPAddressPool
|
||||
metadata:
|
||||
name: local-pool
|
||||
namespace: metallb-system
|
||||
spec:
|
||||
addresses:
|
||||
- 10.240.0.100-10.240.0.250
|
||||
EOF
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
|
||||
- name: Criar anúncio L2
|
||||
shell: |
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: metallb.io/v1beta1
|
||||
kind: L2Advertisement
|
||||
metadata:
|
||||
name: advert
|
||||
namespace: metallb-system
|
||||
EOF
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
|
||||
|
||||
|
||||
- name: Get kubeadm join command
|
||||
become: true
|
||||
shell: kubeadm token create --print-join-command
|
||||
|
||||
@ -10,7 +10,7 @@ with open("/tmp/kube-flannel.yml", "r") as f:
|
||||
for doc in docs:
|
||||
if doc.get("kind") == "ConfigMap" and doc.get("metadata", {}).get("name") == "kube-flannel-cfg":
|
||||
doc["data"]["net-conf.json"] = '''{
|
||||
"Network": "10.244.0.0/16",
|
||||
"Network": "10.240.0.0/16",
|
||||
"Backend": {
|
||||
"Type": "vxlan"
|
||||
},
|
||||
|
||||
@ -88,6 +88,7 @@
|
||||
- kubelet
|
||||
- kubeadm
|
||||
- kubectl
|
||||
- nfs-common
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
@ -161,3 +162,5 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
|
||||
|
||||
67
roles/prowlarr/files/prowlarr-deployment.yaml
Normal file
67
roles/prowlarr/files/prowlarr-deployment.yaml
Normal file
@ -0,0 +1,67 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: prowlarr
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: prowlarr
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: prowlarr
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
containers:
|
||||
- name: prowlarr
|
||||
image: lscr.io/linuxserver/prowlarr:latest
|
||||
securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- containerPort: 9696
|
||||
name: webui
|
||||
env:
|
||||
- name: PUID
|
||||
value: "1013"
|
||||
- name: PGID
|
||||
value: "1013"
|
||||
- name: TZ
|
||||
value: 'Etc/UTC'
|
||||
- name: PROWLARR__POSTGRES__HOST
|
||||
value: 'qbittorrent-service.stack-arr.svc.cluster.local'
|
||||
- name: PROWLARR__POSTGRES__USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prowlarr-secret
|
||||
key: username
|
||||
- name: PROWLARR__POSTGRES__PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prowlarr-secret
|
||||
key: password
|
||||
- name: PROWLARR__POSTGRES__MAINDB
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prowlarr-secret
|
||||
key: maindb
|
||||
- name: PROWLARR__POSTGRES__LOGDB
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prowlarr-secret
|
||||
key: logsdb
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /config
|
||||
volumes:
|
||||
- name: config
|
||||
persistentVolumeClaim:
|
||||
claimName: prowlarr-config-pvc
|
||||
|
||||
|
||||
|
||||
|
||||
11
roles/prowlarr/files/prowlarr-nfs-csi.yaml
Normal file
11
roles/prowlarr/files/prowlarr-nfs-csi.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
apiVersion: storage.k8s.io/v1
|
||||
kind: StorageClass
|
||||
metadata:
|
||||
name: prowlarr-nfs-csi
|
||||
namespace: stack-arr
|
||||
provisioner: nfs.csi.k8s.io
|
||||
parameters:
|
||||
server: 192.168.1.22
|
||||
share: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/stack-arr/prowlarr
|
||||
allowVolumeExpansion: true
|
||||
reclaimPolicy: Retain
|
||||
30
roles/prowlarr/files/prowlarr-pvcs.yaml
Normal file
30
roles/prowlarr/files/prowlarr-pvcs.yaml
Normal file
@ -0,0 +1,30 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: prowlarr-config-pv
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
capacity:
|
||||
storage: 2Gi
|
||||
storageClassName: prowlarr-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
nfs:
|
||||
server: 192.168.1.22
|
||||
path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/stack-arr/prowlarr/config
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: prowlarr-config-pvc
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
storageClassName: prowlarr-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeName: prowlarr-config-pv
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
---
|
||||
11
roles/prowlarr/files/prowlarr-secret.yaml
Normal file
11
roles/prowlarr/files/prowlarr-secret.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: prowlarr-secret
|
||||
namespace: stack-arr
|
||||
type: Opaque
|
||||
data:
|
||||
username: dXNlcm5hbWU=
|
||||
password: cGFzc3dvcmQ=
|
||||
maindb: bWFpbmRiLXByb3dsYXJy
|
||||
logsdb: bG9nZGItcHJvd2xhcnI=
|
||||
51
roles/prowlarr/tasks/main.yml
Normal file
51
roles/prowlarr/tasks/main.yml
Normal file
@ -0,0 +1,51 @@
|
||||
- name: Remover o diretório /tmp/stack-arr/prowlarr/kubernetes-files
|
||||
ansible.builtin.file:
|
||||
path: /tmp/stack-arr/prowlarr/kubernetes-files
|
||||
state: absent
|
||||
|
||||
- name: Criar diretório temporário no remoto
|
||||
file:
|
||||
path: /tmp/stack-arr/prowlarr/kubernetes-files
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy file with owner and permissions
|
||||
ansible.builtin.copy:
|
||||
src: ../files
|
||||
dest: /tmp/stack-arr/prowlarr/kubernetes-files
|
||||
owner: fenix
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
|
||||
- name: Obter várias notas do Bitwarden
|
||||
shell: |
|
||||
echo "unlock"
|
||||
BW_SESSION=$(bw unlock {{ bw_password }} --raw)
|
||||
echo "get item"
|
||||
bw get item "{{ item.id }}" --session $BW_SESSION | jq -r '.notes' > {{ item.dest }}
|
||||
loop:
|
||||
- { id: "iac.ansible.stackarr.prowlarr.secret", dest: "/tmp/stack-arr/prowlarr/kubernetes-files/files/vpn-secret.yaml" }
|
||||
args:
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
BW_PASSWORD: "{{ BW_PASSWORD }}"
|
||||
|
||||
|
||||
- name: Listar conteúdo do diretório remoto
|
||||
shell: ls -l /tmp/stack-arr/prowlarr/kubernetes-files/files
|
||||
register: resultado_ls
|
||||
|
||||
|
||||
- name: Mostrar resultado do ls
|
||||
debug:
|
||||
var: resultado_ls.stdout_lines
|
||||
|
||||
|
||||
- name: Aplicar o stolon
|
||||
become: yes
|
||||
become_user: fenix
|
||||
shell: |
|
||||
kubectl apply -f /tmp/stack-arr/prowlarr/kubernetes-files/files/
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
4
roles/prowlarr/vars/main.yml
Normal file
4
roles/prowlarr/vars/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
bw_password: "{{ lookup('env', 'BW_PASSWORD') }}"
|
||||
VAULTWARDEN_LINK: "{{ lookup('env', 'VAULTWARDEN_LINK') }}"
|
||||
BW_CLIENTID: "{{ lookup('env', 'BW_CLIENTID') }}"
|
||||
BW_CLIENTSECRET : "{{ lookup('env', 'BW_CLIENTSECRET') }}"
|
||||
9
roles/qbittorrent/files/docker-secrets.yaml
Normal file
9
roles/qbittorrent/files/docker-secrets.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: regcred
|
||||
namespace: stack-arr
|
||||
data:
|
||||
.dockerconfigjson: >-
|
||||
eyJhdXRocyI6eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOnsidXNlcm5hbWUiOiJ1c2VyIiwicGFzc3dvcmQiOiJwYXNzIiwiYXV0aCI6ImRmamlla2ZlcldFS1dFa29mY2RrbzM0MzUzZmQ9In19fQ==
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
67
roles/qbittorrent/files/qbittorrent-deployment.yaml
Normal file
67
roles/qbittorrent/files/qbittorrent-deployment.yaml
Normal file
@ -0,0 +1,67 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: qbittorrentvpn
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: qbittorrentvpn
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: qbittorrentvpn
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
containers:
|
||||
- name: qbittorrentvpn
|
||||
image: j4ym0/pia-qbittorrent:5.1.2-ubuntu
|
||||
securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: webui
|
||||
- containerPort: 51413
|
||||
name: torrent-tcp
|
||||
- containerPort: 51413
|
||||
name: torrent-udp
|
||||
protocol: UDP
|
||||
env:
|
||||
- name: USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: vpn-secret
|
||||
key: username
|
||||
- name: PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: vpn-secret
|
||||
key: password
|
||||
- name: REGION
|
||||
value: "us_east" # ou outro servidor PIA
|
||||
- name: WEBUI_PORT
|
||||
value: "8080"
|
||||
- name: DNS_SERVERS
|
||||
value: "1.1.1.1,1.0.0.1"
|
||||
- name: UID
|
||||
value: "1013"
|
||||
- name: GID
|
||||
value: "1013"
|
||||
- name: HOSTHEADERVALIDATION
|
||||
value: 'false'
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /config
|
||||
- name: downloads
|
||||
mountPath: /downloads
|
||||
volumes:
|
||||
- name: config
|
||||
persistentVolumeClaim:
|
||||
claimName: qbittorrent-config-pvc
|
||||
- name: downloads
|
||||
persistentVolumeClaim:
|
||||
claimName: qbittorrent-downloads-pvc
|
||||
4
roles/qbittorrent/files/qbittorrent-namespace.yaml
Normal file
4
roles/qbittorrent/files/qbittorrent-namespace.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: stack-arr
|
||||
11
roles/qbittorrent/files/qbittorrent-nfs-csi.yaml
Normal file
11
roles/qbittorrent/files/qbittorrent-nfs-csi.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
apiVersion: storage.k8s.io/v1
|
||||
kind: StorageClass
|
||||
metadata:
|
||||
name: qbittorrent-nfs-csi
|
||||
namespace: stack-arr
|
||||
provisioner: nfs.csi.k8s.io
|
||||
parameters:
|
||||
server: 192.168.1.22
|
||||
share: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/stack-arr/bittorrent
|
||||
allowVolumeExpansion: true
|
||||
reclaimPolicy: Retain
|
||||
60
roles/qbittorrent/files/qbittorrent-pvcs.yaml
Normal file
60
roles/qbittorrent/files/qbittorrent-pvcs.yaml
Normal file
@ -0,0 +1,60 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: qbittorrent-config-pv
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
capacity:
|
||||
storage: 2Gi
|
||||
storageClassName: qbittorrent-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
nfs:
|
||||
server: 192.168.1.22
|
||||
path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/stack-arr/bittorrent/config
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: qbittorrent-config-pvc
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
storageClassName: qbittorrent-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeName: qbittorrent-config-pv
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: qbittorrent-downloads-pv
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
capacity:
|
||||
storage: 10Gi
|
||||
storageClassName: qbittorrent-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
nfs:
|
||||
server: 192.168.1.22
|
||||
path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/stack-arr/bittorrent/downloads
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: qbittorrent-downloads-pvc
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
storageClassName: qbittorrent-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeName: qbittorrent-downloads-pv
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
---
|
||||
13
roles/qbittorrent/files/qbittorrent-service.yaml
Normal file
13
roles/qbittorrent/files/qbittorrent-service.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: qbittorrent-service
|
||||
namespace: stack-arr
|
||||
spec:
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: qbittorrentvpn
|
||||
type: LoadBalancer
|
||||
loadBalancerIP: 10.240.0.101
|
||||
9
roles/qbittorrent/files/vpn-secret.yaml
Normal file
9
roles/qbittorrent/files/vpn-secret.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: vpn-secret
|
||||
namespace: stack-arr
|
||||
type: Opaque
|
||||
data:
|
||||
username: dXNlcm5hbWU=
|
||||
password: cGFzc3dvcmQ=
|
||||
51
roles/qbittorrent/tasks/main.yml
Normal file
51
roles/qbittorrent/tasks/main.yml
Normal file
@ -0,0 +1,51 @@
|
||||
- name: Remover o diretório /tmp/stack-arr/qbittorrent/kubernetes-files
|
||||
ansible.builtin.file:
|
||||
path: /tmp/stack-arr/qbittorrent/kubernetes-files
|
||||
state: absent
|
||||
|
||||
- name: Criar diretório temporário no remoto
|
||||
file:
|
||||
path: /tmp/stack-arr/qbittorrent/kubernetes-files
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy file with owner and permissions
|
||||
ansible.builtin.copy:
|
||||
src: ../files
|
||||
dest: /tmp/stack-arr/qbittorrent/kubernetes-files
|
||||
owner: fenix
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Obter várias notas do Bitwarden
|
||||
shell: |
|
||||
echo "unlock"
|
||||
BW_SESSION=$(bw unlock {{ bw_password }} --raw)
|
||||
echo "get item"
|
||||
bw get item "{{ item.id }}" --session $BW_SESSION | jq -r '.notes' > {{ item.dest }}
|
||||
loop:
|
||||
- { id: "iac.ansible.stackarr.qbittorrent.dockersecrets", dest: "/tmp/stack-arr/qbittorrent/kubernetes-files/files/docker-secrets.yaml" }
|
||||
- { id: "iac.ansible.stackarr.qbittorrent.secret", dest: "/tmp/stack-arr/qbittorrent/kubernetes-files/files/vpn-secret.yaml" }
|
||||
args:
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
BW_PASSWORD: "{{ BW_PASSWORD }}"
|
||||
|
||||
|
||||
- name: Listar conteúdo do diretório remoto
|
||||
shell: ls -l /tmp/stack-arr/qbittorrent/kubernetes-files/files
|
||||
register: resultado_ls
|
||||
|
||||
- name: Mostrar resultado do ls
|
||||
debug:
|
||||
var: resultado_ls.stdout_lines
|
||||
|
||||
|
||||
- name: Aplicar o qbittorrent
|
||||
become: yes
|
||||
become_user: fenix
|
||||
shell: |
|
||||
kubectl apply -f /tmp/stack-arr/qbittorrent/kubernetes-files/files/qbittorrent-namespace.yaml
|
||||
kubectl apply -f /tmp/stack-arr/qbittorrent/kubernetes-files/files/
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
4
roles/qbittorrent/vars/main.yml
Normal file
4
roles/qbittorrent/vars/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
bw_password: "{{ lookup('env', 'BW_PASSWORD') }}"
|
||||
VAULTWARDEN_LINK: "{{ lookup('env', 'VAULTWARDEN_LINK') }}"
|
||||
BW_CLIENTID: "{{ lookup('env', 'BW_CLIENTID') }}"
|
||||
BW_CLIENTSECRET : "{{ lookup('env', 'BW_CLIENTSECRET') }}"
|
||||
9
roles/stolon/files/docker-secrets.yaml
Normal file
9
roles/stolon/files/docker-secrets.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: regcred
|
||||
namespace: postgresql
|
||||
data:
|
||||
.dockerconfigjson: >-
|
||||
eyJhdXRocyI6eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOnsidXNlcm5hbWUiOiJ1c2VyIiwicGFzc3dvcmQiOiJwYXNzIiwiYXV0aCI6ImRmamlla2ZlcldFS1dFa29mY2RrbzM0MzUzZmQ9In19fQ==
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
126
roles/stolon/files/stolon-keeper.yaml
Normal file
126
roles/stolon/files/stolon-keeper.yaml
Normal file
@ -0,0 +1,126 @@
|
||||
# PetSet was renamed to StatefulSet in k8s 1.5
|
||||
# apiVersion: apps/v1alpha1
|
||||
# kind: PetSet
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: stolon-keeper
|
||||
namespace: postgresql
|
||||
spec:
|
||||
serviceName: "stolon-keeper"
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
component: stolon-keeper
|
||||
stolon-cluster: kube-stolon
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: stolon-keeper
|
||||
stolon-cluster: kube-stolon
|
||||
annotations:
|
||||
pod.alpha.kubernetes.io/initialized: "true"
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "8080"
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
terminationGracePeriodSeconds: 10
|
||||
containers:
|
||||
- name: stolon-keeper
|
||||
image: sorintlab/stolon:master-pg15
|
||||
command:
|
||||
- "/bin/bash"
|
||||
- "-ec"
|
||||
- |
|
||||
|
||||
echo "COMECANDO com user 1013"
|
||||
useradd -u 1013 -r -s /usr/sbin/nologin fenixuser
|
||||
id
|
||||
id stolon
|
||||
# Generate our keeper uid using the pod index
|
||||
IFS='-' read -ra ADDR <<< "$(hostname)"
|
||||
export STKEEPER_UID="keeper${ADDR[-1]}"
|
||||
export POD_IP=$(hostname -i)
|
||||
export STKEEPER_PG_LISTEN_ADDRESS=$POD_IP
|
||||
|
||||
which psql
|
||||
which postgres
|
||||
which pg_ctl
|
||||
|
||||
|
||||
export STOLON_DATA=/stolon-data/data
|
||||
mkdir -p $STOLON_DATA
|
||||
|
||||
|
||||
ls -la $STOLON_DATA
|
||||
|
||||
exec gosu 1013 stolon-keeper --data-dir $STOLON_DATA
|
||||
|
||||
|
||||
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: STKEEPER_CLUSTER_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.labels['stolon-cluster']
|
||||
- name: STKEEPER_STORE_BACKEND
|
||||
value: "kubernetes"
|
||||
- name: STKEEPER_KUBE_RESOURCE_KIND
|
||||
value: "configmap"
|
||||
- name: STKEEPER_PG_REPL_USERNAME
|
||||
#value: "repluser"
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: stolon-repl-secret
|
||||
key: username
|
||||
- name: STKEEPER_PG_REPL_PASSWORD
|
||||
#value: "replpassword"
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: stolon-repl-secret
|
||||
key: password
|
||||
- name: STKEEPER_PG_SU_USERNAME
|
||||
#value: "stolon"
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: stolon-secret
|
||||
key: username
|
||||
- name: STKEEPER_PG_SU_PASSWORDFILE
|
||||
value: "/etc/secrets/stolon/password"
|
||||
- name: STKEEPER_METRICS_LISTEN_ADDRESS
|
||||
value: "0.0.0.0:8080"
|
||||
# Uncomment this to enable debug logs
|
||||
#- name: STKEEPER_DEBUG
|
||||
# value: "true"
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
- containerPort: 8080
|
||||
volumeMounts:
|
||||
- mountPath: /stolon-data
|
||||
name: stolon-data
|
||||
- mountPath: /etc/secrets/stolon
|
||||
name: stolon
|
||||
volumes:
|
||||
- name: stolon
|
||||
secret:
|
||||
secretName: stolon-secret
|
||||
volumeClaimTemplates:
|
||||
- kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: stolon-data
|
||||
namespace: postgresql
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
selector:
|
||||
matchLabels:
|
||||
postgres-id: "stolon-0"
|
||||
4
roles/stolon/files/stolon-namespace.yaml
Normal file
4
roles/stolon/files/stolon-namespace.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: postgresql
|
||||
11
roles/stolon/files/stolon-nfs-csi.yaml
Normal file
11
roles/stolon/files/stolon-nfs-csi.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
apiVersion: storage.k8s.io/v1
|
||||
kind: StorageClass
|
||||
metadata:
|
||||
name: stolon-nfs-csi
|
||||
namespace: postgresql
|
||||
provisioner: nfs.csi.k8s.io
|
||||
parameters:
|
||||
server: 192.168.1.22
|
||||
share: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/postgresql-stolon
|
||||
allowVolumeExpansion: true
|
||||
reclaimPolicy: Retain
|
||||
14
roles/stolon/files/stolon-proxy-service.yaml
Normal file
14
roles/stolon/files/stolon-proxy-service.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: stolon-proxy-service
|
||||
namespace: postgresql
|
||||
spec:
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
component: stolon-proxy
|
||||
stolon-cluster: kube-stolon
|
||||
type: LoadBalancer
|
||||
loadBalancerIP: 10.240.0.100
|
||||
58
roles/stolon/files/stolon-proxy.yaml
Normal file
58
roles/stolon/files/stolon-proxy.yaml
Normal file
@ -0,0 +1,58 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: stolon-proxy
|
||||
namespace: postgresql
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
component: stolon-proxy
|
||||
stolon-cluster: kube-stolon
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: stolon-proxy
|
||||
stolon-cluster: kube-stolon
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "8080"
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
containers:
|
||||
- name: stolon-proxy
|
||||
image: sorintlab/stolon:master-pg10
|
||||
command:
|
||||
- "/bin/bash"
|
||||
- "-ec"
|
||||
- |
|
||||
exec gosu stolon stolon-proxy
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: STPROXY_CLUSTER_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.labels['stolon-cluster']
|
||||
- name: STPROXY_STORE_BACKEND
|
||||
value: "kubernetes"
|
||||
- name: STPROXY_KUBE_RESOURCE_KIND
|
||||
value: "configmap"
|
||||
- name: STPROXY_LISTEN_ADDRESS
|
||||
value: "0.0.0.0"
|
||||
- name: STPROXY_METRICS_LISTEN_ADDRESS
|
||||
value: "0.0.0.0:8080"
|
||||
## Uncomment this to enable debug logs
|
||||
#- name: STPROXY_DEBUG
|
||||
# value: "true"
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: 5432
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
111
roles/stolon/files/stolon-pvcs.yaml
Normal file
111
roles/stolon/files/stolon-pvcs.yaml
Normal file
@ -0,0 +1,111 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: stolon-pv-0
|
||||
namespace: postgresql
|
||||
labels:
|
||||
postgres-id: "stolon-0"
|
||||
spec:
|
||||
capacity:
|
||||
storage: 10Gi
|
||||
storageClassName: stolon-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
nfs:
|
||||
server: 192.168.1.22
|
||||
path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/postgresql-stolon/keeper-0
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: stolon-pv-1
|
||||
namespace: postgresql
|
||||
labels:
|
||||
postgres-id: "stolon-0"
|
||||
spec:
|
||||
capacity:
|
||||
storage: 10Gi
|
||||
storageClassName: stolon-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
nfs:
|
||||
server: 192.168.1.22
|
||||
path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/postgresql-stolon/keeper-1
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: stolon-pv-2
|
||||
namespace: postgresql
|
||||
labels:
|
||||
postgres-id: "stolon-0"
|
||||
spec:
|
||||
capacity:
|
||||
storage: 10Gi
|
||||
storageClassName: stolon-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
nfs:
|
||||
server: 192.168.1.22
|
||||
path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/postgresql-stolon/keeper-2
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: stolon-data-stolon-keeper-0
|
||||
namespace: postgresql
|
||||
labels:
|
||||
postgres-id: "stolon-0"
|
||||
spec:
|
||||
storageClassName: stolon-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeName: stolon-pv-0
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
selector:
|
||||
matchLabels:
|
||||
postgres-id: "stolon-0"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: stolon-data-stolon-keeper-1
|
||||
namespace: postgresql
|
||||
labels:
|
||||
postgres-id: "stolon-0"
|
||||
spec:
|
||||
storageClassName: stolon-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeName: stolon-pv-1
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
selector:
|
||||
matchLabels:
|
||||
postgres-id: "stolon-0"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: stolon-data-stolon-keeper-2
|
||||
namespace: postgresql
|
||||
labels:
|
||||
postgres-id: "stolon-0"
|
||||
spec:
|
||||
storageClassName: stolon-nfs-csi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeName: stolon-pv-2
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
selector:
|
||||
matchLabels:
|
||||
postgres-id: "stolon-0"
|
||||
---
|
||||
9
roles/stolon/files/stolon-repl-secret.yaml
Normal file
9
roles/stolon/files/stolon-repl-secret.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: stolon-repl-secret
|
||||
namespace: postgresql
|
||||
type: Opaque
|
||||
data:
|
||||
username: asOndDQ5aWZqa2w0aW85
|
||||
password: asOndDQ5aWZqa2w0aW85
|
||||
13
roles/stolon/files/stolon-role-binding.yaml
Normal file
13
roles/stolon/files/stolon-role-binding.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: stolon-role-binding
|
||||
namespace: postgresql
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: stolon-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: default
|
||||
namespace: postgresql
|
||||
14
roles/stolon/files/stolon-role.yaml
Normal file
14
roles/stolon/files/stolon-role.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: stolon-role
|
||||
namespace: postgresql
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
- configmaps
|
||||
- events
|
||||
verbs:
|
||||
- "*"
|
||||
9
roles/stolon/files/stolon-secret.yaml
Normal file
9
roles/stolon/files/stolon-secret.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: stolon-secret
|
||||
namespace: postgresql
|
||||
type: Opaque
|
||||
data:
|
||||
username: asOndDQ5aWZqa2w0aW85
|
||||
password: asOndDQ5aWZqa2w0aW85
|
||||
50
roles/stolon/files/stolon-sentinel.yaml
Normal file
50
roles/stolon/files/stolon-sentinel.yaml
Normal file
@ -0,0 +1,50 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: stolon-sentinel
|
||||
namespace: postgresql
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
component: stolon-sentinel
|
||||
stolon-cluster: kube-stolon
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: stolon-sentinel
|
||||
stolon-cluster: kube-stolon
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "8080"
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
containers:
|
||||
- name: stolon-sentinel
|
||||
image: sorintlab/stolon:master-pg10
|
||||
command:
|
||||
- "/bin/bash"
|
||||
- "-ec"
|
||||
- |
|
||||
exec gosu stolon stolon-sentinel
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: STSENTINEL_CLUSTER_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.labels['stolon-cluster']
|
||||
- name: STSENTINEL_STORE_BACKEND
|
||||
value: "kubernetes"
|
||||
- name: STSENTINEL_KUBE_RESOURCE_KIND
|
||||
value: "configmap"
|
||||
- name: STSENTINEL_METRICS_LISTEN_ADDRESS
|
||||
value: "0.0.0.0:8080"
|
||||
## Uncomment this to enable debug logs
|
||||
#- name: STSENTINEL_DEBUG
|
||||
# value: "true"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
72
roles/stolon/tasks/main.yml
Normal file
72
roles/stolon/tasks/main.yml
Normal file
@ -0,0 +1,72 @@
|
||||
- name: Remover o diretório /tmp/stolon/kubernetes-files
|
||||
ansible.builtin.file:
|
||||
path: /tmp/stolon/kubernetes-files
|
||||
state: absent
|
||||
|
||||
- name: Criar diretório temporário no remoto
|
||||
file:
|
||||
path: /tmp/stolon/kubernetes-files
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy file with owner and permissions
|
||||
ansible.builtin.copy:
|
||||
src: ../files
|
||||
dest: /tmp/stolon/kubernetes-files
|
||||
owner: fenix
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Listar conteúdo do diretório remoto
|
||||
shell: ls -l /tmp/stolon/kubernetes-files/files
|
||||
register: resultado_ls
|
||||
|
||||
|
||||
- name: Obter várias notas do Bitwarden
|
||||
shell: |
|
||||
echo "unlock"
|
||||
BW_SESSION=$(bw unlock {{ bw_password }} --raw)
|
||||
echo "get item"
|
||||
bw get item "{{ item.id }}" --session $BW_SESSION | jq -r '.notes' > {{ item.dest }}
|
||||
loop:
|
||||
- { id: "iac.ansible.dockersecrets", dest: "/tmp/stolon/kubernetes-files/files/docker-secrets.yaml" }
|
||||
- { id: "iac.ansible.stolon.repl.secret", dest: "/tmp/stolon/kubernetes-files/files/stolon-repl-secret.yaml" }
|
||||
- { id: "iac.ansible.stolon.keeper.secret", dest: "/tmp/stolon/kubernetes-files/files/stolon-secret.yaml" }
|
||||
args:
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
BW_PASSWORD: "{{ BW_PASSWORD }}"
|
||||
|
||||
|
||||
- name: Mostrar resultado do ls
|
||||
debug:
|
||||
var: resultado_ls.stdout_lines
|
||||
|
||||
- name: Aplicar o stolon
|
||||
become: yes
|
||||
become_user: fenix
|
||||
shell: |
|
||||
kubectl apply -f /tmp/stolon/kubernetes-files/files/stolon-namespace.yaml
|
||||
kubectl apply -f /tmp/stolon/kubernetes-files/files/
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
|
||||
- name: Verificar se o cluster Stolon já existe
|
||||
shell: kubectl get configmap -n postgresql kube-stolon
|
||||
register: stolon_cluster_check
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
become_user: fenix
|
||||
environment:
|
||||
KUBECONFIG: /home/fenix/.kube/config
|
||||
|
||||
|
||||
#run this if first time setting up database
|
||||
#- name: Aplicar o stolon
|
||||
# become: yes
|
||||
# become_user: fenix
|
||||
# shell: |
|
||||
# kubectl run -i -n=postgresql -t stolonctl --image=sorintlab/stolon:master-pg15 --restart=Never --rm -- /usr/local/bin/stolonctl --cluster-name=kube-stolon --store-backend=kubernetes --kube-resource-kind=configmap init --yes
|
||||
# when: stolon_cluster_check.rc != 0
|
||||
# environment:
|
||||
# KUBECONFIG: /home/fenix/.kube/config
|
||||
4
roles/stolon/vars/main.yml
Normal file
4
roles/stolon/vars/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
bw_password: "{{ lookup('env', 'BW_PASSWORD') }}"
|
||||
VAULTWARDEN_LINK: "{{ lookup('env', 'VAULTWARDEN_LINK') }}"
|
||||
BW_CLIENTID: "{{ lookup('env', 'BW_CLIENTID') }}"
|
||||
BW_CLIENTSECRET : "{{ lookup('env', 'BW_CLIENTSECRET') }}"
|
||||
77
roles/vaultwarden/tasks/main.yml
Normal file
77
roles/vaultwarden/tasks/main.yml
Normal file
@ -0,0 +1,77 @@
|
||||
- name: Atualizar pacotes e instalar dependências básicas
|
||||
become: true
|
||||
apt:
|
||||
name:
|
||||
- curl
|
||||
- git
|
||||
- unzip
|
||||
- jq
|
||||
- gnupg
|
||||
- ca-certificates
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Adicionar repositório NodeSource para Node.js 20
|
||||
become: true
|
||||
shell: curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Instalar Node.js 20
|
||||
become: true
|
||||
apt:
|
||||
name: nodejs
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Verificar versão do Node.js
|
||||
command: node -v
|
||||
register: node_version
|
||||
changed_when: false
|
||||
|
||||
- name: Verificar versão do npm
|
||||
command: npm -v
|
||||
register: npm_version
|
||||
changed_when: false
|
||||
|
||||
- name: Instalar Bitwarden CLI via npm
|
||||
become: true
|
||||
shell: npm install -g @bitwarden/cli
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Verificar instalação do Bitwarden CLI
|
||||
command: bw --version
|
||||
register: bw_version
|
||||
failed_when: bw_version.rc != 0
|
||||
|
||||
- name: Garantir logout do Bitwarden antes de configurar
|
||||
shell: bw logout
|
||||
ignore_errors: true
|
||||
|
||||
- name: Fazer login no Bitwarden
|
||||
shell: |
|
||||
echo "config"
|
||||
echo "VAULTWARDEN_LINK: {{ VAULTWARDEN_LINK }}"
|
||||
bw config server {{ VAULTWARDEN_LINK }}
|
||||
echo $BW_CLIENTID
|
||||
echo $BW_CLIENTSECRET
|
||||
echo "login"
|
||||
bw login --apikey
|
||||
environment:
|
||||
BW_CLIENTID: "{{ BW_CLIENTID }}"
|
||||
BW_CLIENTSECRET: "{{ BW_CLIENTSECRET }}"
|
||||
VAULTWARDEN_LINK: "{{ VAULTWARDEN_LINK }}"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: bw_login
|
||||
|
||||
- name: Desbloquear cofre e guardar sessão
|
||||
shell: bw unlock {{ bw_password }} --raw
|
||||
register: bw_session
|
||||
environment:
|
||||
BW_PASSWORD: "{{ BW_PASSWORD }}"
|
||||
|
||||
- name: Exportar sessão para ambiente local
|
||||
shell: echo "export BW_SESSION={{ bw_session.stdout }}" >> /etc/profile.d/bw-session.sh
|
||||
become: true
|
||||
4
roles/vaultwarden/vars/main.yml
Normal file
4
roles/vaultwarden/vars/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
bw_password: "{{ lookup('env', 'BW_PASSWORD') }}"
|
||||
VAULTWARDEN_LINK: "{{ lookup('env', 'VAULTWARDEN_LINK') }}"
|
||||
BW_CLIENTID: "{{ lookup('env', 'BW_CLIENTID') }}"
|
||||
BW_CLIENTSECRET : "{{ lookup('env', 'BW_CLIENTSECRET') }}"
|
||||
Reference in New Issue
Block a user