mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-ansible-private.git
synced 2026-03-22 20:39:48 +00:00
Compare commits
81 Commits
kubernetes
...
f532ff4507
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 |
@ -2,7 +2,7 @@ name: IACAnsible
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ kubernetes-vazio ]
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@ -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 }}
|
||||
@ -3,13 +3,16 @@
|
||||
become: yes
|
||||
roles:
|
||||
- common
|
||||
- vaultwarden
|
||||
- kubernetes
|
||||
- kube-master
|
||||
- stolon
|
||||
|
||||
- name: Configure Kubernetes Nodes
|
||||
hosts: workers
|
||||
become: yes
|
||||
roles:
|
||||
- common
|
||||
- vaultwarden
|
||||
- kubernetes
|
||||
- kube-node
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
|
||||
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
|
||||
114
roles/stolon/files/stolon-keeper.yaml
Normal file
114
roles/stolon/files/stolon-keeper.yaml
Normal file
@ -0,0 +1,114 @@
|
||||
# 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"
|
||||
- |
|
||||
id stolon
|
||||
id root
|
||||
# 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
|
||||
mkdir -p /stolon-data/data
|
||||
export STOLON_DATA=/stolon-data/data
|
||||
chown root:root /stolon-data
|
||||
chown root:root $STOLON_DATA
|
||||
exec gosu root stolon-keeper --data-dir $STOLON_DATA
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
runAsGroup: 0
|
||||
allowPrivilegeEscalation: true
|
||||
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: data
|
||||
- mountPath: /etc/secrets/stolon
|
||||
name: stolon
|
||||
volumes:
|
||||
- name: stolon
|
||||
secret:
|
||||
secretName: stolon-secret
|
||||
volumeClaimTemplates:
|
||||
- kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: data
|
||||
namespace: postgresql
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
storageClassName: stolon-nfs-csi
|
||||
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: 192.168.1.105
|
||||
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
|
||||
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
|
||||
70
roles/stolon/tasks/main.yml
Normal file
70
roles/stolon/tasks/main.yml
Normal file
@ -0,0 +1,70 @@
|
||||
- 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
|
||||
|
||||
#- name: Aplicar o stolon
|
||||
# become: yes
|
||||
# become_user: fenix
|
||||
# shell: |
|
||||
# kubectl run -i -n=postgresql -t stolonctl --image=sorintlab/stolon:master-pg10 --restart=Never --rm -- /usr/local/bin/stolonctl --cluster-name=kube-stolon --store-backend=kubernetes --kube-resource-kind=configmap init
|
||||
# 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