zoukankan      html  css  js  c++  java
  • saltstack入门个人笔记

    offical website

    reference1

    reference2

    1. install
    apt-get install python-software-properties
    apt install software-properties-common
    apt-get update
    apt-get install salt-master
    apt-get install salt-minion
    
    1. config

    if master: vim /etc/salt/master

    interface: master ip		            //(注意:key:空格value之间不能漏掉空格,否则报错)
    auto_accept: True
    

    if minion: vim /etc/salt/minon

    master: master ip
    id: minion ip
    
    1. usual salt cmd //(salt, salt-run, salt-cp 适用于master)
    salt-call test.ping					    //(适用master and minion)
    salt 'hostname' test.ping 				//(适用minion)
    //(可选)/etc/salt/minion_id:存放minion master: Accepted Keys
    salt-key -L						        // list all salt-key 
    salt '*' cmd.run 'df -lh'				//master run cmd on minion host
    salt-call cmd.run 'hostname -I' 		//minion run cmd on minion host 
    salt-run manage.down     			    //查看所有没在线minion
    salt-run manage.up       				//查看所有在线minion
    salt-key -a minion_key				    //接受某个minion-key 大写A介绍所有
    salt-key -d minion_key				    //删除某个minion-key大写D删除所有
    //将master中的文件复制到制定minion主机,可重命名
    salt-cp 'minion_ip' master_txt minion_dir/rename.txt		
    salt '*' pkg.version python 			//显示软件包版本信息
    salt '*' pkg.install git 				//install git on minion
    salt '*' pkg.install pkgs=['vim','rpm']		//install two more pkgs
    salt '*' network.connect google-public-dns-a.google.com port=53 proto=udp
    salt '*' service.start mysql 			//启动mysql服务
    salt '*' cmd.run 'service mysql start'
    
    1. get data

    A. Grains are used to get static data about your systems

    B. Salt pillar is used to deliver data to your systems.

    C. SaltStack configuration management lets you create a re-usable configuration template, called a state

    salt -G 'os:Ubuntu' test.ping			//static data Grains
    salt -E '192.168.43.*' test.ping		//regular expression
    salt -L 'minion1,minion2' test.ping 	//in a list
    
    1. salt state
      vim /srv/salt/nettools.sls
    install_id_whatever:
      pkg.installed:
        - pkgs:                             // multi pkgs
          - rsync
          - lftp
          - curl
        - name: git                         //single pkg
    
    run cmd to install pkgs in nettools.sls on minion host

    salt '*' state.apply nettools
    or
    salt '*' state.sys nettools.sls

    vim /srv/salt/test.sls

    install_id_test:
        pkg.install:
            -pkgs:
                - mysql-server
                - django
    

    vim /srv/salt/top.sls

    base:
        '*':
            - nettools
        'specific_minion_host'
            - test
    

    salt '*' state.apply // default use top.sls

    salt 'specific_minion_host' state.apply test.sls

    1. to be continue
  • 相关阅读:
    导出redis中某个大key中的值并与数据库中作对比
    添加印记脚本
    校园信息流读请求脚本
    每天一个linux命令(1):which命令(转)
    (转)Jmeter内存溢出处理方式记录
    提升效率(时间准确性),减少时间和资源的消耗——由89C52/89C51的定时器中断引出的一些问题
    STM32重映射(PinRemap)的使用,注意!
    Terminal中输入命令直接打开QtCreator,以及创建其桌面快捷方式
    MarkDown插入图片
    初试MarkDown
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/9122169.html
Copyright © 2011-2022 走看看