-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (109 loc) · 3.41 KB
/
setup-agent.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Only Setup Agent
on:
pull_request:
push:
paths:
- '.github/workflows/setup-agent.yaml'
workflow_dispatch:
branches:
- main
defaults:
run:
working-directory: ./playbook
env:
TZ: Asia/Shanghai
REPO: "artifact.onwalk.net"
IMAGE: base/${{ github.repository }}
TAG: ${{ github.sha }}
DNS_AK: ${{ secrets.DNS_AK }}
DNS_SK: ${{ secrets.DNS_SK }}
PASSWORD: ${{ secrets.ADMIN_INIT_PASSWORD }}
DEBIAN_FRONTEND: noninteractive
HELM_EXPERIMENTAL_OCI: 1
jobs:
setup-k3s:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: update submodule
run: |
sudo apt-get update && sudo apt-get install -y git && git submodule update --init --recursive
- name: Setup K3S Cluster
shell: bash
run: |
export ANSIBLE_HOST_KEY_CHECKING=False
sudo apt install jq ansible -y
mkdir -pv ~/.ssh/
cat > ~/.ssh/id_rsa << EOF
${{ secrets.SSH_PRIVATE_KEY }}
EOF
sudo chmod 0400 ~/.ssh/id_rsa
md5sum ~/.ssh/id_rsa
mkdir -pv hosts/
steps:
- uses: actions/checkout@v3
- name: update submodule
run: |
sudo apt-get update && sudo apt-get install -y git && git submodule update --init --recursive
- name: Setup K3S Cluster
shell: bash
run: |
export ANSIBLE_HOST_KEY_CHECKING=False
sudo apt install jq ansible -y
mkdir -pv ~/.ssh/
cat > ~/.ssh/id_rsa << EOF
${{ secrets.SSH_PRIVATE_KEY }}
EOF
sudo chmod 0400 ~/.ssh/id_rsa
md5sum ~/.ssh/id_rsa
mkdir -pv hosts/
cat > hosts/inventory << EOF
[master]
${{ secrets.APP_HOST_DOMAIN }} ansible_host=${{ secrets.APP_HOST_IP }}
[all:vars]
ansible_port=22
ansible_ssh_user=${{ secrets.APP_HOST_USER }}
ansible_ssh_private_key_file=~/.ssh/id_rsa
ansible_host_key_checking=False
ingress_ip=${{ secrets.APP_HOST_IP }}
dns_ak=$DNS_AK
dns_sk=$DNS_SK
EOF
cat hosts/inventory
ansible-playbook -i hosts/inventory init_k3s_cluster_std -D
setup-agent:
runs-on: ubuntu-latest
needs:
- setup-k3s
steps:
- uses: actions/checkout@v3
- name: update submodule
run: |
sudo apt-get update && sudo apt-get install -y git && git submodule update --init --recursive
- name: Pre setup for Ansible playbook
run: |
sudo apt install jq ansible -y
mkdir -pv ~/.ssh/
cat > ~/.ssh/id_rsa << EOF
${{ secrets.SSH_PRIVATE_KEY }}
EOF
sudo chmod 0400 ~/.ssh/id_rsa
md5sum ~/.ssh/id_rsa
- name: Setup Observability Agent
shell: bash
run: |
export ANSIBLE_HOST_KEY_CHECKING=False
mkdir -pv hosts/
cat > hosts/k3s << EOF
[master]
${{ secrets.APP_HOST_DOMAIN }} ansible_host=${{ secrets.APP_HOST_IP }}
[all:vars]
ansible_port=22
ansible_ssh_user=${{ secrets.APP_HOST_USER }}
ansible_ssh_private_key_file=~/.ssh/id_rsa
ansible_host_key_checking=False
admin_password=$PASSWORD
dns_ak=$DNS_AK
dns_sk=$DNS_SK
EOF
ansible-playbook -i hosts/k3s init_observability-agent -D