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

相关推荐

  • 安全及数字认证等使用

    偏重实现ca数字认证及实现基于key的登录

    2018-05-19
  • Apache介绍及常用配置

    Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。

    2018-06-21
  • 06葵花宝典之linux网络、进程管理和shell循环语句

    06葵花宝典之linux网络、进程管理和shell循环语句 作为服务器,其输入输出功能在大多数时候都是通过网络提供的,网络功能对于服务器而言是至关重要的。 一、OSI七层模型和TCP/IP四层模型 1、OSI七层模型 OSI七层模型是参考ISO(International Standard Organization国际标准化组织)所指定的一个用于通信系统间互…

    2018-04-15
  • Linux 部分使用命令

    说明Linux系统上命令的使用格式;详细介绍ifconfig、echo、tty、startx、export、pwd、history、shutdown、poweroff、reboot、hwclock、date命令的使用,并配合相应的示例来阐述。

    Linux笔记 2018-06-24
  • 运维第一周小结

    运维有运行和维护两层含义。对于一个系统,有时出错我们无法预知,系统越复杂,其维护难度越大,为了减少损失,我们尽可能地去预防各种错误,对于突发情况,尽可能地去修复。 平时我们所接触的大都是window的图形界面,而Linux却是另外一种风格,他完全是由命令来进行操作的一种系统,那么要想学好我觉得命令是最重要的,不仅要会使用常用的命令还要学会使用不常用的命令会通…

    2018-03-31