salt 之 学习环境搭建

快速开始

新到一家公司使用了salt,这打破了我一直使用ansible的习惯,硬着头皮快速开始吧

  1. 使用docker环境快速学习
    master的Dockerfile

    FROM centos:7
    RUN curl -fsSL https://repo.saltproject.io/py3/redhat/7/x86_64/3004.repo | tee /etc/yum.repos.d/salt.repo && \
    sed -i "s/repo.saltproject.com/mirrors.aliyun.com\/saltstack/g" /etc/yum.repos.d/salt.repo &&\
    yum install salt-master -y

    minion的Dockerfile

    FROM centos:7
    RUN curl -fsSL https://repo.saltproject.io/py3/redhat/7/x86_64/3004.repo | tee /etc/yum.repos.d/salt.repo && \
    sed -i "s/repo.saltproject.com/mirrors.aliyun.com\/saltstack/g" /etc/yum.repos.d/salt.repo &&\
    yum install salt-minion -y
  2. 启动容器

    #!/bin/bash
    docker rm -f salt-master
    docker rm -f salt-minion
    docker network rm bridmv
    docker network create -d macvlan --subnet=10.4.7.0/24 --gateway=10.4.7.254 -o parent=eth0 -o macvlan_mode=bridge bridmv
    docker run -d --net=bridmv --privileged --name=salt-minion --ip 10.4.7.60 centos7:salt-minio tail -f /dev/null
    docker run -d --net=bridmv --privileged --name=salt-master --ip 10.4.7.61 centos7:salt-master /usr/bin/salt-master --log-level=debug
  3. 配置minion连接到master
    3.1修改minion配置文件

    docker exec -it salt-minion bash
    [root@9b3d6af908c2 /]# vi /etc/salt/minion
    master:
    - 10.4.7.61

    3.2启动minion服务

    docker exec -it salt-minion bash
    [root@9b3d6af908c2 /]# /usr/bin/salt-minion

    3.3服务端接受minion发起的连接

    [root@allinone salt]# docker exec -it salt-master salt-key -a 9b3d6af908c2
    The following keys are going to be accepted:
    Unaccepted Keys:
    9b3d6af908c2
    Proceed? [n/Y] y
    Key for minion 9b3d6af908c2 accepted.

    查看已接受的key

    [root@allinone salt]# docker exec -it salt-master salt-key
    Accepted Keys:
    9b3d6af908c2
    Denied Keys:
    Unaccepted Keys:
    Rejected Keys:
  4. master端测试

    [root@allinone salt]# docker exec -it salt-master salt '*' test.ping
    9b3d6af908c2:
    True

至此已经完成了salt的学习环境搭建

posted @   mingtian是吧  阅读(54)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
点击右上角即可分享
微信分享提示