Saltstack的配置管理salt.states
跳到导航
跳到搜索
最简单的sls state
vim /srv/salt/top.sls #正则匹配 base: '*': - webserver vim /srv/salt/webserver.sls lynx: # 标签定义 pkg: # state declaration - installed # function declaration 第一行被称为(ID declaration) 标签定义,在这里被定义为安装包的名。注意:在不同发行版软件包命名不同,比如 fedora 中叫httpd的包 Debian/Ubuntu中叫apache2 第二行被称为(state declaration)状态定义, 在这里定义使用(pkg state module) 第三行被称为(function declaration)函数定义, 在这里定义使用(pkg state module)调用 installed 函数 salt '*' state.highstate -v test=True salt '*' state.highstate 2.9 配置管理从这里开始 p27 1.查看支持的所有states 列表 salt 'gitlabzbx' sys.list_state_modules gitlabzbx: - alias - alternatives - apt - archive - artifactory - beacon - bigip 5. 从一个简单的实例理解states cat /srv/salt/one.sls /tmp/foo.conf: file.managed: - source: salt://foo.conf - user: root - group: root - mode: 644 - backup: minion root@myxp:~# echo "salt books" > /srv/salt/foo.conf 这样就把 master上的 /src/salt/foo.conf 分发到 minon的 /tmp/foo.conf root@myxps:/srv/salt# salt '*' state.sls one zbxAgent: ---------- ID: /tmp/foo.conf Function: file.managed Result: True Comment: File /tmp/foo.conf updated Started: 08:31:01.737749 Duration: 45.764 ms Changes: ---------- diff: New file mode: 0644 Summary for zbxAgent ------------ Succeeded: 1 (changed=1) Failed: 0 ------------ Total states run: 1 Total run time: 45.764 ms gitlabzbx: ---------- ID: /tmp/foo.conf