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
9 Commits
d460624689
...
fecbc54b79
| Author | SHA1 | Date | |
|---|---|---|---|
| fecbc54b79 | |||
| d693a947f2 | |||
| 8c882adffe | |||
| fff458af5a | |||
| de1925a486 | |||
| 2fdee619ca | |||
| 47411136d0 | |||
| 08a0bb3761 | |||
| 27b924b558 |
@ -1,3 +1,6 @@
|
|||||||
# iac-ansible-private
|
# 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
|
||||||
@ -6,7 +6,6 @@
|
|||||||
- vaultwarden
|
- vaultwarden
|
||||||
- kubernetes
|
- kubernetes
|
||||||
- kube-master
|
- kube-master
|
||||||
- stolon
|
|
||||||
|
|
||||||
- name: Configure Kubernetes Nodes
|
- name: Configure Kubernetes Nodes
|
||||||
hosts: workers
|
hosts: workers
|
||||||
@ -16,3 +15,10 @@
|
|||||||
- vaultwarden
|
- vaultwarden
|
||||||
- kubernetes
|
- kubernetes
|
||||||
- kube-node
|
- kube-node
|
||||||
|
|
||||||
|
- name: Configure Kubernetes Data
|
||||||
|
hosts: master
|
||||||
|
become: yes
|
||||||
|
roles:
|
||||||
|
- stolon
|
||||||
|
- qbittorrent
|
||||||
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" # 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
|
||||||
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
|
||||||
11
roles/qbittorrent/files/stolon-nfs-csi.yaml
Normal file
11
roles/qbittorrent/files/stolon-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
|
||||||
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=
|
||||||
52
roles/qbittorrent/tasks/main.yml
Normal file
52
roles/qbittorrent/tasks/main.yml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
- 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: Listar conteúdo do diretório remoto
|
||||||
|
shell: ls -l /tmp/stack-arr/qbittorrent/kubernetes-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.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: 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/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') }}"
|
||||||
@ -11,4 +11,4 @@ spec:
|
|||||||
component: stolon-proxy
|
component: stolon-proxy
|
||||||
stolon-cluster: kube-stolon
|
stolon-cluster: kube-stolon
|
||||||
type: LoadBalancer
|
type: LoadBalancer
|
||||||
#loadBalancerIP: 192.168.1.105
|
loadBalancerIP: 10.240.0.100
|
||||||
Reference in New Issue
Block a user