File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ control_nodes :
2+ hosts :
3+ token_node :
4+ ansible_host :
5+ config_file:
Original file line number Diff line number Diff line change 1+ control_nodes :
2+ hosts :
3+ token_node :
4+ ansible_host :
5+ config_file :
6+ optional_control_node_1 :
7+ ansible_host :
8+ config_file :
9+ optional_control_node_2 :
10+ ansible_host :
11+ config_file :
12+
13+ agent_nodes :
14+ hosts :
15+ optional_agent_1 :
16+ ansible_host :
17+ config_file :
18+ optional_agent_2 :
19+ ansible_host :
20+ config_file :
21+ optional_agent_3 :
22+ ansible_host :
23+ config_file:
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Copy rke2 configuration files
3+ hosts : all
4+ become : true
5+ tasks :
6+ - include_tasks : ../tasks/rke2/copy_config.yml
7+
8+ - name : Install and run rke2-server.service on first control node
9+ hosts : control_nodes
10+ become : true
11+ tasks :
12+ - include_tasks : ../tasks/rke2/install_first_server.yml
13+
14+ - name : Get node-token from a control node
15+ hosts : control_nodes
16+ become : true
17+ tasks :
18+ - include_tasks : ../tasks/rke2/get_registration_token.yml
19+
20+ - name : Add node-token to other control nodes and agent nodes configuration
21+ hosts : control_nodes:agent_nodes
22+ become : true
23+ tasks :
24+ - include_tasks : ../tasks/rke2/add_token_to_config.yml
25+
26+ - name : Install and run rke2-server.service on rest of the control nodes
27+ hosts : control_nodes
28+ become : true
29+ tasks :
30+ - include_tasks : ../tasks/rke2/install_other_servers.yml
31+
32+ - name : Install and run rke2-agent.service on agent nodes
33+ hosts : agent_nodes
34+ become : true
35+ tasks :
36+ - include_tasks : ../tasks/rke2/install_agents.yml
37+
38+ - name : Make kubectl executable available for ansible_user
39+ hosts : control_nodes
40+ become : true
41+ tasks :
42+ - include_tasks : ../tasks/rke2/provide_kubectl.yml
43+
44+ - name : Deploy k8s secrets
45+ hosts : control_nodes
46+ become : true
47+ tasks :
48+ - include_tasks : ../tasks/rke2/deploy_secrets.yml
49+
50+ - name : Install metallb
51+ hosts : control_nodes
52+ tasks :
53+ - include_tasks : ../tasks/rke2/install_metallb.yml
54+
55+ - name : Install SC4S helm repo
56+ hosts : control_nodes
57+ tasks :
58+ - include_tasks : ../tasks/rke2/install_helm_repo.yml
59+
60+ - name : Deploy SC4S app
61+ hosts : control_nodes
62+ tasks :
63+ - include_tasks : ../tasks/rke2/deploy_app.yml
64+
65+
Original file line number Diff line number Diff line change 1+ apiVersion : metallb.io/v1beta1
2+ kind : IPAddressPool
3+ metadata :
4+ namespace : metallb
5+ name : my-ip-pool
6+ spec :
7+ addresses :
8+ # Configure address pool for metallb
9+ # - 1.2.3.4/32
10+ ---
11+ apiVersion : metallb.io/v1beta1
12+ kind : L2Advertisement
13+ metadata :
14+ namespace : metallb
15+ name : l2-advertisement
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Add rke2 token to config
3+ lineinfile :
4+ path : /etc/rancher/rke2/config.yaml
5+ regexp : ' ^token:'
6+ line : " token: {{ hostvars['token_node'].rke2_token }}"
7+ create : yes
8+ when : inventory_hostname != "token_node"
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Create /etc/rancher/rke2 directory
3+ file :
4+ path : /etc/rancher/rke2
5+ state : directory
6+ mode : u=rw,g=rw,o=r
7+
8+ - name : Copy the configuration file to the remote location
9+ copy :
10+ src : " {{ config_file }}"
11+ dest : /etc/rancher/rke2/config.yaml
12+ owner : " {{ ansible_user }}"
13+ group : " {{ ansible_user }}"
14+ mode : u=rw,g=rw,o=r
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Copying values.yml file on the server
3+ copy :
4+ src : /opt/charts/splunk-connect-for-syslog/values.yaml
5+ dest : " /home/{{ ansible_user }}/values.yaml"
6+ owner : " {{ ansible_user }}"
7+ group : " {{ ansible_user }}"
8+ mode : u=rw,g=rw,o=r
9+
10+ - name : Deploy app or update it with new values if already deployed
11+ block :
12+ - name : Deploy sc4s app from templates with overwrites from values.yml
13+ ansible.builtin.shell : helm install sc4s splunk-connect-for-syslog/splunk-connect-for-syslog -f values.yaml
14+ args :
15+ chdir : " /home/{{ ansible_user }}/"
16+ rescue :
17+ - name : Update app with new values.yml
18+ ansible.builtin.shell : helm upgrade sc4s splunk-connect-for-syslog/splunk-connect-for-syslog -f values.yaml
19+ args :
20+ chdir : " /home/{{ ansible_user }}/"
21+ when : inventory_hostname == "token_node"
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Load k8s secrets
3+ include_vars :
4+ file : " {{ item }}"
5+ with_first_found :
6+ - files :
7+ - /opt/ansible/resources/k8s_secrets.yaml
8+ - /opt/charts/splunk-connect-for-syslog/secrets.yaml
9+
10+ - name : Export kubectl bin path
11+ shell : export PATH=$PATH:/var/lib/rancher/rke2/bin/
12+
13+ - name : Create mTLS secret
14+ ansible.builtin.shell : |
15+ /var/lib/rancher/rke2/bin/kubectl apply -f - <<EOF
16+ apiVersion: v1
17+ kind: Secret
18+ metadata:
19+ name: {{ hec_tls.secret }}
20+ type: Opaque
21+ data:
22+ key.pem: {{ hec_tls.value.key | b64encode }}
23+ cert.pem: {{ hec_tls.value.cert | b64encode }}
24+ ca_cert.pem: {{ hec_tls.value.ca | b64encode }}
25+ EOF
26+ when :
27+ - hec_tls is defined
28+ - ('secret' in hec_tls) and ('value' in hec_tls)
29+ - inventory_hostname == "token_node"
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Wait for rke2 token to be ready
3+ wait_for :
4+ path : /var/lib/rancher/rke2/server/node-token
5+ timeout : 60
6+ when : inventory_hostname == "token_node"
7+
8+ - name : Retrieve the rke2 node token
9+ shell : cat /var/lib/rancher/rke2/server/node-token
10+ register : node_token
11+ when : inventory_hostname == "token_node"
12+
13+ - name : Set the node token as a fact for worker nodes
14+ set_fact :
15+ rke2_token : " {{ node_token.stdout }}"
16+ when : inventory_hostname == "token_node"
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Run the installer
3+ shell : curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE="agent" sh -
4+
5+ - name : Enable and start rke2-agent.service
6+ service :
7+ name : rke2-agent.service
8+ enabled : yes
9+ state : started
You can’t perform that action at this time.
0 commit comments