ansible_playbook


– hosts: all
remote_user: root

vars:
ports:
-81
-82
-83

vars:
ports:
– listen_port: 81
– listen_port: 82
– listen_port: 83

vars:
ports:
– web1:
port: 81
#name: web1.mnixiao.com
rootdir: /root/web1
– web2:
port: 82
name: web2.mnixiao.com
rootdir: /root/web2
– web3:
port: 83
#name: web3.mnixiao.com
rootdir: /root/web3

vars_files:
– vars.yml

vars:
– haha:
xixi: ni111
hehe: xiao222
– pipi:
jj: dajj
qq: xiaoqq

tasks:
– name: creat some file
group: name={{ item }}
when: ansible_distribution_major_version == “7”
with_items:
– g1
– g2
– g3
– name: add some users
user: name={{ item.name }} group={{ item.group }} state=present
with_items:
– { name: ‘user1’, group: ‘g1’}
– { name: ‘user2’, group: ‘g2’}
– { name: ‘user3’, group: ‘g3’}

– name: install httpd package
yum: name=httpd
tags: anzhuanghttpd

– name: copy template for centos7
template: src=nginx.conf7.j2 dest=/etc/nginx/nginx.conf
when: ansible_distribution_major_version == “7”
(when: ansible_os_family == “RedHat”)
notify:
– Restart Nginx
– Check Nginx Process

– name: copy template for centos7
Module: Args || /bin/true

Module: Args
ignore_errors: True

– name: test connection
ping:
remote_user: magedu
sudo: yes
sudo_user: wang

handlers:
– name: Restart Nginx
service: name=nginx state=restarted enabled=yes
– name: Check Nginx process
shell: killall -0 nginx > /tmp/nginx.log

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/104172

(0)
倪潇洒倪潇洒
上一篇 2018-07-30 01:54
下一篇 2018-07-30

相关推荐

  • if,case,for 脚本练习

    shell脚本练习

    2018-05-06
  • 搭建主DNS服务器

    DNS笔记

    2018-05-30
  • 计算机及Linux基础知识

    1、描述计算机的组成及其功能 根据冯诺依曼体系结构,计算机由运算器、存储器、控制器、输入设备和输出设备五个基本部件组成,其中运算器和控制器合称为中央处理器(CPU)。 各基本部件的功能是: 存储器用于存放指令和数据; 控制器控制指令自动执行; 运算器进行加、减、乘、除四种基本算术运算以及逻辑运算和附加运算;输入输出设备通过和主机进行通信,完成人机数据交互。 …

    2018-06-23
  • awk

    awk介绍awk里表示字符串要用双引号引起来awk:Aho, Weinberger, Kernighan,报告生成器,格式化文本输出有多种版本:New awk(nawk),GNU awk( gawk)gawk:模式扫描和处理语言基本用法:awk [options] ‘program’ var=value file… 选项,程序(语言),变量赋值awk [op…

    Linux笔记 2018-05-20