Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit f920dba

Browse files
author
Fiona
committed
grains should be fixed meow.
1 parent b8065ee commit f920dba

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"python.pythonPath": "/usr/bin/python3"
2+
"python.pythonPath": "C:\\Python27\\python.exe",
3+
"python.linting.pylintEnabled": false
34
}

_grains/k8sgrain.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import socket
2+
# define hostname
23
hostname = socket.gethostname()
3-
if 'k8s' in hostname:
4-
def k8s_grain():
5-
grains = {}
6-
grains[role] = 'master'
7-
if '01' in hostname:
8-
role = 'master'
9-
else:
10-
role = 'worker'
11-
k8s = {'role': role, 'cluster': 'k8spi'}
12-
return k8s
13-
print(k8s)
14-
15-
else:
16-
print("Not a k8s node, no cluster for you")
17-
184

5+
# If hostname contains "k8s" assign the role "master" for 01, else "worker".
6+
def get_k8s_name():
7+
k8s_role_dict = {'k8s role': ''}
8+
if 'k8s' in hostname:
9+
if '01' in hostname:
10+
k8s_role_dict['k8s role'] = 'master'
11+
else:
12+
k8s_role_dict['k8s role'] = 'worker'
13+
return k8s_role_dict

consul/files/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"data_dir": "/opt/consul",
66
"bind_addr": "192.168.2.13",
77
"client_addr": "192.168.2.13",
8-
"ui": true
8+
"ui": true,
9+
"raft_protocol": "3"
910
}

consul/init.sls

+8-3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ consul:
5454

5555
copy consul config:
5656
file.managed:
57-
- name:
58-
- source: salt://{{slspath}}/files/consul.service
59-
- mode: 644
57+
- name: /etc/consul.d/config.json
58+
- source: salt://{{slspath}}/files/config.json
59+
- mode: 644
60+
- makedirs: True
61+
- user: consul
62+
- group: consul
63+
- require:
64+
- user: consul user

0 commit comments

Comments
 (0)