zoukankan      html  css  js  c++  java
  • salt 一些state模块函数的使用方法记录

    file模块

    file.managed  下发文件

    /tmp/test.txt:  ##执行ID
      file.managed:  ##使用的模块函数
        - name: /tmp/bbb.txt  ##目标,如果不写,会取ID做目标的值
        - source: salt://file/test.txt  ##源文件,这里用的是salt的file_roots目录
        - user: root  ##拥有者
        - group: root  ##拥有组
        - mode: 666  ##权限位

    file.directory   建立目录

    /home/cong/test:
      file.directory:
        - user: cong
        - group: cong
        - mode: 755
        - makedirs: True

    file.symlink  建立软连接

    /tmp/aaa.txt
      file.symlink:
        - target: /etc/passwd

    file.recurse  下发整个目录

    /tmp/test_dir:
      file.rescurse:
        - source: salt//file/zabbix
        - include_empty: True

    pkg模块

    pkg.installed 软件安装

    soft_install:
      pkg.installed:
        - name: httpd

    #可以指定版本或版本范围

    soft_install:
      pkg.installed:
        - pkgs:
          - httpd: 2.4
          - php
          - mysql-server: '>= 5.6'

    #安装指导来源

    soft_install:
      pkg.installed:
        - pkgs:
          - httpd: salt://file/httpd/httpd.rpm
          - mysql-server: http://www.mysql.com/path/mysql-server.rpm
          - php: ftp://path/php.rpm
          - foo: /usr/local/src/foo.rpm

    指定安装最新版的软件

    [root@cong-33 test]# cat install.sls 
    mypkgs:
      pkg.latest:
        - pkgs:
          - httpd
          - vim-enhanced
    [root@cong-33 test]#

    service 

    redis:
      service.running:
        - enable: True
        - reload: True
        - watch:
          - pkg: redis

    cron

    date >/tmp/test.txt:
      cron.present:
        - user: root
        - minute: '*/5'

    user模块

    adduser:
      user.present:
        - name: cong
        - fullname: lycong
        - shell: /bin/bash
        - home: /home/cong
        - uid: 4000
        - gid: 4000
        - groups:
          - cong
          - root
          - games
  • 相关阅读:
    oracle 导入数据语句
    移动上去换样式代码
    google suggest 代码例子
    删除一个表的字段的sql语句命令
    将json从前台传到后台注意问题
    eclipse 自动 getter setter 注释
    jsp界面获取地址栏参数
    常见的正则表达式验证
    JSTL 核心标签库
    javascript中的call和apply两个方法的区别
  • 原文地址:https://www.cnblogs.com/LYCong/p/7988164.html
Copyright © 2011-2022 走看看