码迷,mamicode.com
首页 > 其他好文 > 详细

ansible-playbook(1)

时间:2019-02-09 22:25:34      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:lock   roles   gid   led   bsp   hoc   OLE   nginx   create   

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

 

ansible-playbook(1)

标签:lock   roles   gid   led   bsp   hoc   OLE   nginx   create   

原文地址:https://www.cnblogs.com/c040/p/10358082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!