标签:认证 说明 控制 四种 tip ble 远程 pre ice
1. 主机规划服务器名称 | 操作系统版本 | 内网IP | 外网IP(模拟) | Hostname | 部署模块 |
---|---|---|---|---|---|
salt100 | CentOS7.5 | 172.16.1.100 | 10.0.0.100 | salt100 | salt-master、salt-minion |
salt01 | CentOS7.5 | 172.16.1.11 | 10.0.0.11 | salt01 | salt-minion |
salt02 | CentOS7.5 | 172.16.1.12 | 10.0.0.12 | salt01 | salt-minion |
salt03 | CentOS7.5 | 172.16.1.13 | 10.0.0.13 | salt01 | salt-minion |
salt100、salt01、salt02、salt03的hosts文件都追加如下信息。
这样主机名相互之间可以解析。
[root@salt100 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.11 salt01
172.16.1.12 salt02
172.16.1.13 salt03
172.16.1.14 salt04
172.16.1.15 salt05
172.16.1.100 salt100
1、 运维人员使用的登录账号;
2、 所有的业务都放在 /app/ 下「yun用户的家目录」,避免业务数据乱放;
3、 该用户也可用于后期salt-ssh使用,因为几乎所有的生产环境都是禁止root远程登录的(因此进行了 sudo 提权)。
# 使用一个专门的用户,避免直接使用root用户
# 添加用户、指定家目录并指定用户密码
useradd -u 1050 -d /app yun && echo ‘123456‘ | /usr/bin/passwd --stdin yun
# sudo提权
echo "yun ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# 让其它普通用户可以进入该目录查看信息
chmod 755 /app/
监控
执行
配置管理
Local
Minion/Master C/S
Syndic 代理方式
Salt SSH
在salt100、salt01、salt02、salt03机器上执行
yum install -y https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm
根据规划在salt100安装salt的master和minion,在其他机器安装salt的minion。
yum install -y salt-master salt-minion
yum install -y salt-minion
[root@salt100 ~]# salt --version # master版本查看
salt 2018.3.3 (Oxygen)
[root@salt100 ~]# salt-minion --version # minion版本查看
salt-minion 2018.3.3 (Oxygen)
在salt100上执行,无需任务配置修改
[root@salt100 ~]# systemctl start salt-master.service
1、 minion端指向的master是哪个
2、 minion端的ID是什么
[root@salt100 salt]# pwd
/etc/salt
[root@salt100 salt]# vim minion
………………
# 可以是IP或者hostname
# 如果是hostname那么必须能够解析【最佳实践配置为 主机名】
master: salt100
………………
# Explicitly declare the id for this minion to use, if left commented the id
# will be the hostname as returned by the python call: socket.getfqdn()
# Since salt uses detached ids it is possible to run multiple minions on the
# same machine but with different ids, this can be useful for salt compute
# clusters.
# 如果id不配置,那么默认为hostname
# 如果下次要更改该配置,那么要把 /etc/salt/minion_id 也给删除掉,并重启客户端【会生成一个新的minion_id】
#id:
………………
[root@salt100 ~]# systemctl start salt-minion.service
systemctl enable salt-master.service
systemctl enable salt-minion.service
[root@salt100 salt]# pwd
/etc/salt
[root@salt100 salt]# ll
total 128
-rw-r----- 1 root root 2926 Oct 8 23:56 cloud
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.conf.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.deploy.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.maps.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.profiles.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.providers.d
-rw-r----- 1 root root 51532 Oct 8 23:56 master
drwxr-xr-x 2 root root 6 Oct 9 00:42 master.d
-rw-r----- 1 root root 36072 Nov 25 23:01 minion
drwxr-xr-x 2 root root 6 Oct 9 00:42 minion.d
-rw-r--r-- 1 root root 7 Nov 25 23:05 minion_id
drwxr-xr-x 4 root root 34 Nov 25 22:41 pki
-rw-r----- 1 root root 28162 Oct 8 23:56 proxy
drwxr-xr-x 2 root root 6 Oct 9 00:42 proxy.d
-rw-r----- 1 root root 344 Oct 8 23:56 roster
[root@salt100 salt]# tree pki/
pki/
├── master
│ ├── master.pem
│ ├── master.pub
│ ├── minions
│ ├── minions_autosign
│ ├── minions_denied
│ ├── minions_pre # master还未进一步认证【接受或拒绝】,minion的公钥都先放在这里
│ │ ├── salt01
│ │ ├── salt02
│ │ ├── salt03
│ │ └── salt100
│ └── minions_rejected
└── minion
├── minion.pem
└── minion.pub
7 directories, 8 files
[root@salt03 salt]# pwd
/etc/salt
[root@salt03 salt]# ll
total 128
-rw-r----- 1 root root 2926 Oct 8 23:56 cloud
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.conf.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.deploy.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.maps.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.profiles.d
drwxr-xr-x 2 root root 6 Oct 9 00:42 cloud.providers.d
-rw-r----- 1 root root 51532 Oct 8 23:56 master
drwxr-xr-x 2 root root 6 Oct 9 00:42 master.d
-rw-r----- 1 root root 36000 Nov 25 23:12 minion
drwxr-xr-x 2 root root 6 Oct 9 00:42 minion.d
-rw-r--r-- 1 root root 6 Nov 25 23:12 minion_id
drwxr-xr-x 4 root root 34 Nov 25 22:41 pki
-rw-r----- 1 root root 28162 Oct 8 23:56 proxy
drwxr-xr-x 2 root root 6 Oct 9 00:42 proxy.d
-rw-r----- 1 root root 344 Oct 8 23:56 roster
[root@salt03 salt]# tree pki/
pki/
├── master
└── minion
├── minion.pem
└── minion.pub
2 directories, 2 files
[root@salt100 salt]# salt-key
Accepted Keys:
Denied Keys:
Unaccepted Keys:
salt01
salt02
salt03
salt100
Rejected Keys:
[root@salt100 salt]# salt-key -a salt01 # 单个接受
The following keys are going to be accepted:
Unaccepted Keys:
salt01
Proceed? [n/Y] y
Key for minion salt01 accepted.
[root@salt100 salt]# salt-key
Accepted Keys:
salt01
Denied Keys:
Unaccepted Keys:
salt02
salt03
salt100
Rejected Keys:
[root@salt100 salt]# salt-key -a salt0*
The following keys are going to be accepted:
Unaccepted Keys:
salt02
salt03
Proceed? [n/Y] y
Key for minion salt02 accepted.
Key for minion salt03 accepted.
[root@salt100 salt]# salt-key
Accepted Keys:
salt01
salt02
salt03
Denied Keys:
Unaccepted Keys:
salt100
Rejected Keys:
[root@salt100 salt]# salt-key -A
The following keys are going to be accepted:
Unaccepted Keys:
salt100
Proceed? [n/Y] y
Key for minion salt100 accepted.
[root@salt100 salt]# salt-key
Accepted Keys:
salt01
salt02
salt03
salt100
Denied Keys:
Unaccepted Keys:
Rejected Keys:
[root@salt100 salt]# pwd
/etc/salt
[root@salt100 salt]# tree pki/
pki/
├── master
│ ├── master.pem
│ ├── master.pub
│ ├── minions # minion的公钥从minions_pre 移到了此目录
│ │ ├── salt01
│ │ ├── salt02
│ │ ├── salt03
│ │ └── salt100
│ ├── minions_autosign
│ ├── minions_denied
│ ├── minions_pre
│ └── minions_rejected
└── minion
├── minion_master.pub # 接受了来自master的公钥
├── minion.pem
└── minion.pub
7 directories, 9 files
[root@salt03 salt]# tree pki/
pki/
├── master
└── minion
├── minion_master.pub # 接受了来自master的公钥
├── minion.pem
└── minion.pub
2 directories, 3 files
[root@salt100 salt]# salt ‘*‘ test.ping # 看master可以控制哪些minion
salt02:
True
salt03:
True
salt01:
True
salt100:
True
标签:认证 说明 控制 四种 tip ble 远程 pre ice
原文地址:https://blog.51cto.com/9410445/2369042