Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How saltstack initializes minion

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how saltstack initializes minion, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Many people will struggle with the question between saltstack and ansible, which is saltstack or ansible. First of all, we have to be aware of the advantages and disadvantages between them.

Saltstack is based on the zero mq messaging system and can achieve high concurrency (in theory, a salt-master can run a thousand minion, which can be executed in a short time), while ansible is based on ssh, and each request requires the establishment of a ssh connection, so it is inefficient, but it does not need to install the client, and saltstack needs to install the client, that is, saltstack minion. This article focuses on how to quickly deploy the minion client in saltstack.

First of all, suppose a scenario in which we buy a CVM in a cloud (Aliyun / Tencent Cloud, etc.) (the host is bound with the key of salt-master). How can this host (minion) be managed by salt-master? We can write a script specifically to initialize minon, and the script must be executed on the salt-master machine.

Current environment

IP address hostname role

10.0.0.61 m01 salt-master

10.0.0.8 web01 newly initialized host

1. The initialization script for minion is as follows

#! / bin/bashHost=$1sshpass='/usr/bin/sshpass'# determines the number of parameters passed by the script if [$#-ne 1]; then echo "Please input use args {host}" exit 1fi# first determines whether the target host can reach ping-c 3-W 1 ${Host} > / dev/null 2 > & 1if [$?-ne 0] Then echo "destination host ${Host} unreachable" exit 1else echo "destination host ${Host} reachable" fi# add salt rpm source DATA1='ls / etc/yum.repos.d/salt-py3-*.repo'$ {sh4pass} ssh ${Host}-o StrictHostKeyChecking=no "${DATA1}" > / dev/null 2 > & 1if [$?-eq 0] Then echo "salt-minion rpm package installed" exit 1else echo "salt-minion rpm package not installed" fiDATA2='sudo yum install-y https://repo.saltstack.com/py3/redhat/salt-py3-repo-2019.2.el7.noarch.rpm'${shpass} ssh ${Host}-o StrictHostKeyChecking=no "${DATA2}" > / dev/null 2 > & 1if [$?-eq 0] Then echo "add salt rpm Source-> ${DATA2} successful" else echo "add salt rpm Source-> ${DATA2} failed" exit 1fi# installation salt-minionDATA3='yum install-y salt-minion'$ {shpass} ssh ${Host}-o StrictHostKeyChecking=no "${DATA3}" > / dev/null 2 > & 1if [$?-eq 0] Then echo "install salt-minion-> ${DATA3} successfully" else echo "install salt-minion-> ${DATA3} failed" exit 1fi# modify salt-minion configuration file DATA4= "sed-I's @ ^ # master:.*@master: 10.0.0.61DATA4= / etc/salt/minion" echo "modify configuration file ${DATA4}" ${shpass} ssh ${Host}-o StrictHostKeyChecking=no "${DATA4}" > / dev/null 2 > & 1if [$?-eq 0] Then echo "modify salt-minion configuration file-> ${DATA4} successful" else echo "modify salt-minion configuration file-> ${DATA4} failed" exit 1fi# restart salt-minionDATA5='systemctl restart salt-minion'$ {shpass} ssh ${Host}-o StrictHostKeyChecking=no "${DATA5}" > / dev/null 2 > & 1if [$?-eq 0] Then echo "restart salt-minion-> ${DATA5} succeeded" else echo "restart salt-minion-> ${DATA5} failed" exit 1fi

2. After executing the script

The above is all the content of the article "how saltstack initializes minion". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report