最近对这三种工具进行了粗略的学习,画了张图.
涵盖不全面,也可能理解的有错误,暂时先就这样.如有大牛路过,还请斧正!
更:
ansible salt 简单分发配置对比,安装httpd cp文件 新建用户
ansible
[root/etc/ansible] ]$tree
├── roles
│ └── httpd
│ ├── default
│ ├── files
│ │ └── ansible.html
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ └── vars
│ └── main.yml
└── work
└── httpd.yml
10 directories, 8 files
[root/etc/ansible] ]$cat roles/httpd/tasks/main.yml
- name: install httpd
yum: name=httpd state=present
- name: test file
copy: src=ansible.html dest=/var/www/html/
notify: restart httpd
- name: start httpd
service: name=httpd state=started enabled=true
- name: create user
user: name={{ username }} state=present
[root/etc/ansible] ]$cat roles/httpd/vars/main.yml
username:
user01
[root/etc/ansible] ]$cat roles/httpd/handlers/main.yml
- name: restart httpd
service: name=httpd state=restarted
[root/etc/ansible] ]$cat work/httpd.yml
- name: install httpd
hosts: testgroup
user: root
roles:
- httpd
salt
[root/srv/salt] ]$tree
├── httpd
│ ├── file
│ │ └── saltstack.html
│ ├── files.sls
│ ├── init.sls
│ ├── server.sls
│ └── user.sls
└── top.sls
3 directories, 7 files
[root/srv/salt] ]$cat httpd/init.sls
include:
- httpd.files
- httpd.server
- httpd.user
[root/srv/salt] ]$cat httpd/files.sls
/var/www/html/saltstack.html:
file.managed:
- user: root
- group: root
- mode: 644
- source: salt://httpd/file/saltstack.html
- require:
- pkg: httpd
[root/srv/salt] ]$cat httpd/server.sls
server:
pkg:
- name: httpd
- installed
[root/srv/salt] ]$cat httpd/user.sls
salt-test:
user.present:
- fullname: salt-test-user
- shell: /bin/bash
- groups:
- root
[root/srv/salt] ]$cat top.sls
base:
'minion-01':
- httpd
网友评论