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

Saltstack installation

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

Share

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

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