ansible-playbook(1)

ansible-playbook(1)

 

Ansible组成部分
Inventory
Modules
Ad Hoc Commands
playbooks
playbooks:
Tasks: 任务,即调用的模块完成的某操作
variables:变量
Templates:模版
Roles:角色

 

基本结构:
- host: webserver
remote_user:
tasks:
- task1
  module_name: MODULE_NAME
- task2

 

简单实例1: 创建用户及组
- hosts: all
remote_user: root
tasks:
- name: create nginx group
  group: name=nginx system=yes gid=208
- name: create nginx user
  user: name=nginx uid=208 group=nginx system=yes

简单实例2: 安装应用服务并开机自启动
- hosts: all
remote_user: root
tasks:
- name: install httpd package
  yum: name=httpd state=latest
- name: install configuration file for httpd
  copy: src=/root/conf/httpd.conf dest=/etc/httpd/conf/httpd.conf
- name: start httpd service
  service: enabled=true name=httpd state=started

 

猜你喜欢

转载自www.cnblogs.com/c040/p/10358082.html