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
  • 相关阅读:
    oracle 11g 中 (oracle 10g) crsctl 的 替换命令
    BZOJ 2792 Poi2012 Well 二分答案
    java基础入门-多线程同步浅析-以银行转账为样例
    CF 316div2 E.Pig and Palindromes
    Linux 性能监控 —— Load Average
    UISearchBar cancel 按钮设置文本
    UISlider 设置增量
    推荐一个在线json数据格式化网站
    解决ARC下performselector-may-cause-a-leak-because-its-selector-is-unknown 警告
    UITextView 添加 pleaceholder
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/9122169.html
Copyright © 2011-2022 走看看