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

Installation and configuration of saltstack

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

SaltStack management tools allow administrators to create a consistent management system for multiple operating systems, including VMware vSphere environments.

SaltStack acts on servant and master topologies. SaltStack in combination with specific commands can be executed on one or more subordinates. To achieve this, Salt Master can issue commands such as salt'* 'cmd.run' ls-l /'.

In addition to running remote commands, SaltStack allows administrators to use "grain". Grain can run remote queries on SaltStack servants, so collect status information for servants and allow administrators to store information in a central location. SaltStack can also help administrators define the expected state on the target system. These states are applied using .sls files, which contain very specific requirements on how to obtain the desired state on the system.

Server installation

1) download the corresponding version of the extended source configuration file epel.repo from the Ali Cloud image address http://mirrors.aliyun.com/repo/ and upload it to the local / etc/yum.repos.d directory

2) yum install salt-master

Systemctl enable salt-master.service

Mkdir-p / srv/salt/ {dev,prod}

Edit configuration file / etc/salt/master

[

File_roots:

Base:

/ srv/salt/

Dev:/srv/salt/dev

Prod:/srv/salt/prod

]

Systemctl start salt-master.service

Client installation

1) just like the server installation, upload epel.repo to the local / etc/yum.repos.d directory

2) yum install salt-minion

Systemctl enable salt-minion.service

Edit configuration file / etc/salt/minion

[

Master: 192.168.233.100

Id: test01

]

Systemctl start salt-minion.service

Add Host

Execute salt-key-L on the master node to view the minion nodes that can be added

Execute salt-key-A to add all nodes, select y, and then use salt-key-L to view the following:

4. Common command

1) Test connectivity salt 'test01' test.ping

2) execute the command salt 'test01' cmd.run' df-h' remotely

3) File distribution salt-cp''/ etc/hosts / etc

4) use sls script

① transfers files only

The contents and documents are prepared as shown in the picture.

Sample hosts.sls:

/ etc/hosts:

File.managed:

Source: salt://files/hostsuser: rootgroup: rootmode: 644

Execute salt 'test01' state.sls saltenv='prod' sls.hosts

② transfers files and executes commands

The catalogue and documents are prepared as shown in the figure:

Jq.sls:

/ usr/local/src/oniguruma-5.9.5-3.el7.art.x86_64.rpm:

File.managed:

Source: salt://base/files/oniguruma-5.9.5-3.el7.art.x86_64.rpmuser: rootgroup: rootmode: 755

/ usr/local/src/jq-1.5-1.el7.art.x86_64.rpm:

File.managed:

Source: salt://base/files/jq-1.5-1.el7.art.x86_64.rpmuser: rootgroup: rootmode: 755

/ usr/local/src/jq.sh:

File.managed:

Source: salt://base/scripts/jq.shuser: rootgroup: root

Mode: 755

Cmd.run:

Cwd: / usr/local/srcname: sh / usr/local/src/jq.shunless: test-d / usr/local/src/jq.shrequire:file: / usr/local/src/jq.sh

Jq.sh:

Cd / usr/local/src

Rpm-ivh oniguruma-5.9.5-3.el7.art.x86_64.rpm

Rpm-ivh jq-1.5-1.el7.art.x86_64.rpm

Execute salt 'test01' state.sls saltenv='prod' sls.jq

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: 267

*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