All Projects → BigbigY → salt-ssh-install-salt-minion

BigbigY / salt-ssh-install-salt-minion

Licence: other
利用salt-ssh批量部署salt-minion

Programming Languages

SaltStack
118 projects
shell
77523 projects

Projects that are alternatives of or similar to salt-ssh-install-salt-minion

generate-secure-pillar
Salt Secure Pillar Tool
Stars: ✭ 30 (+57.89%)
Mutual labels:  salt, saltstack
saltstack-lxc-vagrant
Vagrantfile for setting up a SaltStack test/dev environment.
Stars: ✭ 13 (-31.58%)
Mutual labels:  salt, saltstack
saltdash
A read-only dashboard for Salt jobs
Stars: ✭ 18 (-5.26%)
Mutual labels:  salt, saltstack
salt-lint
A command-line utility that checks for best practices in SaltStack.
Stars: ✭ 111 (+484.21%)
Mutual labels:  salt, saltstack
saltstack-cheatsheet
🧂 SaltStack Cheat Sheet Plus
Stars: ✭ 31 (+63.16%)
Mutual labels:  salt, saltstack
pepperboard
Simple and modular dashboard toolkit for SaltStack
Stars: ✭ 26 (+36.84%)
Mutual labels:  salt, saltstack
alcali-formula
Saltstack formula to install Alcali: a web based tool(GUI) for monitoring and administrating Saltstack Salt.
Stars: ✭ 15 (-21.05%)
Mutual labels:  salt, saltstack
ISalt
ISalt: Interactive Salt Programming
Stars: ✭ 61 (+221.05%)
Mutual labels:  salt, saltstack
community
SaltStack Community
Stars: ✭ 27 (+42.11%)
Mutual labels:  salt, saltstack
salt-netapi-client
Java bindings for the Salt API
Stars: ✭ 78 (+310.53%)
Mutual labels:  salt, salt-minion
vscode-saltstack
SaltStack extension for Microsoft Visual Studio Code
Stars: ✭ 26 (+36.84%)
Mutual labels:  salt, saltstack
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+15636.84%)
Mutual labels:  saltstack
Salt Vagrant Demo
Demo of Salt in Vagrant. 1 master and 2 minions
Stars: ✭ 228 (+1100%)
Mutual labels:  saltstack
Alcali
Featureful Saltstack GUI
Stars: ✭ 218 (+1047.37%)
Mutual labels:  saltstack
idy
👓 An ID obfuscator for ActiveRecord
Stars: ✭ 15 (-21.05%)
Mutual labels:  salt
Metalk8s
An opinionated Kubernetes distribution with a focus on long-term on-prem deployments
Stars: ✭ 217 (+1042.11%)
Mutual labels:  saltstack
mobileid
Mobile ID Sample Scripts
Stars: ✭ 13 (-31.58%)
Mutual labels:  salt
Ewp oms
自动化运维系统(saltstack+django+bootstrap),QQ群342844540,博客http://ywzhou.blog.51cto.com
Stars: ✭ 211 (+1010.53%)
Mutual labels:  saltstack
ceph-formula
docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Stars: ✭ 14 (-26.32%)
Mutual labels:  saltstack
salt-toaster
Salt Toaster: An ultimate test suite for Salt
Stars: ✭ 24 (+26.32%)
Mutual labels:  salt

Saltstack?

Salt 一种全新的基础设施管理方式,部署轻松,在几分钟内可运行起来,扩展性好,很容易管理上万台服务器,速度够快,服务器之间秒级通讯。

salt底层采用动态的连接总线, 使其可以用于编配, 远程执行, 配置管理等等.

批量部署salt-minion客户端

大规模部署salt的时候,为了减轻运维工作,需要批量来安装salt-minion客户端。

salt-ssh是Saltstack的另一种管理方式,无需安装minion端,可以运用Salt的一切功能,管理和使用方式和基本和Salt一样。但是执行效率会比有minion端慢很多,不适合大规模批量操作

环境:

192.168.1.14  服务端:salt-ssh salt-master salt-minion
192.168.1.15  客户端:salt-minion
192.168.1.16  客户端:salt-minion
192.168.1.17  客户端:salt-minion

一、salt-ssh安装(master端)

1、克隆代码:

$ git clone https://github.com/BigbigY/salt-ssh-install-salt-minion.git

2、导入SaltStack存储密钥:

$ rpm --import SALTSTACK-GPG-KEY.pub

3、将saltstack.repo拷贝到/etc/yum.repos.d/

4、Run sudo yum clean expire-cache.

5、Run sudo yum update.

6、安装salt-ssh

提示:salt-ssh不需要启动服务,只需要启动下salt-master服务

$ yum -y install salt-ssh salt-master
$ systemctl start salt-master

二、配置salt-ssh客户端信息,通信

1、ip文件:

把所有minion_ip放到文件中,格式如下:

$ cat host_ip.txt 
192.168.1.14
192.168.1.15
192.168.1.16
192.168.1.17

2、批量添加脚本:

USERNAME是客户端用户名,PASSWORD是客户端密码,这里的话客户端账号密码都相同,所有我写了个批量添加的脚本

$ cat ip.sh
#!/bin/bash
USERNAME="root"
PASSWORD="123"
for i in `cat /root/host_ip.txt`
do
        echo "$i:" >> /etc/salt/roster ##$i表示取文件的每行内容
        echo "  host: $i" >> /etc/salt/roster
        echo "  user: $USERNAME" >>/etc/salt/roster
        echo "  passwd: $PASSWORD" >>/etc/salt/roster
#        echo "  sudo: True" >>/etc/salt/roster
        echo "  timeout: 10" >>/etc/salt/roster
done

3、执行,查看

$ cat /etc/salt/roster
# Sample salt-ssh config file
#web1:
#  host: 192.168.42.1 # The IP addr or DNS hostname
#  user: fred         # Remote executions will be executed as user fred
#  sudo: True         # Whether to sudo to root, not enabled by default
#web2:
#  host: 192.168.42.2
192.168.1.14:
  host: 192.168.1.14
  user: root
  passwd: 123
  timeout: 10
192.168.1.15:
  host: 192.168.1.15
  user: root
  passwd: 123
  timeout: 10
192.168.1.16:
  host: 192.168.1.16
  user: root
  passwd: 123
  timeout: 10
192.168.1.17:
  host: 192.168.1.17
  user: root
  passwd: 123
  timeout: 10

4、测试

$ salt-ssh -i '*' test.ping
192.168.1.17:
    True
192.168.1.14:
    True
192.168.1.16:
    True
192.168.1.15:
    True

三、批量安装salt-minion

1、目录结构:

$ pwd
/srv/salt
$ tree minions/
minions/
├── 5
│   └── README.md
├── 6
│   └── README.md
└── 7
    ├── conf
    │   ├── minion
    │   ├── SALTSTACK-GPG-KEY.pub
    │   └── saltstack.repo
    └── install.sls

4 directories, 6 files

2、需要在控制端/etc/hosts文件增加Host解析(master)

$ cat /etc/hosts
192.168.1.14  salt.node1.com
192.168.1.15  salt.node2.com
192.168.1.16  salt.node3.com
192.168.1.17  salt.node4.com

3、执行:

minion配置文件根据自己master_ip修改,id根据自身情况获取

$ pwd
/srv/salt
salt-ssh -i '*' state.sls minions.7.install

4、查看需要授权的主机:

$ salt-key
Accepted Keys:
Denied Keys:
Unaccepted Keys:
192.168.1.14
192.168.1.15
192.168.1.16
192.168.1.17
Rejected Keys:

5、授权要管理的主机:

$ salt-key -A
The following keys are going to be accepted:
Unaccepted Keys:
192.168.1.14
192.168.1.15
192.168.1.16
192.168.1.17
Proceed? [n/Y] y
Key for minion 192.168.1.14 accepted.
Key for minion 192.168.1.15 accepted.
Key for minion 192.168.1.16 accepted.
Key for minion 192.168.1.17 accepted.

查看

$ salt-key
Accepted Keys:
192.168.1.14
192.168.1.15
192.168.1.16
192.168.1.17
Denied Keys:
Unaccepted Keys:
Rejected Keys:

6、salt测试

$ salt '*' test.ping
192.168.1.14:
    True
192.168.1.15:
    True
192.168.1.16:
    True
192.168.1.17:
    True

7、取消salt-ssh:

在/etc/salt/roster清除添加的认证主机

8、测试

$ salt '*' test.ping
192.168.1.14:
    True
192.168.1.15:
    True
192.168.1.16:
    True
192.168.1.17:
    True

温馨提示: 此篇以ip为minion_id,如果需要根据主机名,可以先把主机名写命名好,然后改写install.sls grains获取改成host主机名就可以了。 或者可以自己编写个grains模块来获取。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].