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 08:25

相关推荐

  • 小节

    管道符:cmd1 输出cmd2 输入cmd1 | cmd2如果想将错误信息传给cmd2cmd1 |& cmd2 或 cmd1 2>&1| cmd2加上 >2><&>就是重定向<< key与用户名和组相关的/etc/passwd/etc/shadow 放用户口令的/etc/group/etc/g…

    Linux笔记 2018-04-07
  • RHEL7.2搭建yum源

    我在RHEL7.2搭建本地yum时发现突然报错了。 查看了一下报错信息显示 加载插件:langpacks,产品ID,搜索禁用回购,订阅管理器该系统未注册到红帽订阅管。你可以使用subscription-m急于注册.repolist:0由于Redhat的yum在线更新是收费的,如果没有注册的话是不能使用的,即不能在线安装软件。 我只好用CentOS的yum来替…

    2018-04-19
  • 第4周作业

     1、复制/etc/shel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 [root@localhost ~]# cp -r /etc/shel /home/tuser1 [root@localhost ~]# chmod -R 700 /home/tuser1  2、编辑/etc/group文…

    Linux笔记 2018-06-04
  • Linux启动和内核管理

    系统启动和内核管理 Linux组成 Linux:kerne+rootfs(应用程序) kernel:进程管理、内存管理、网络管理、驱动程序、文件系统、安全功能 roots:程序和glibc 函数:相当于命令的集合 库:函数集合,function,调用接口(头文件负责描述) 过程调用:procedure,无返回值 函数调用:function 程序:二进制执行文…

    Linux笔记 2018-05-13
  • LVS负载调度器,

    集群概念 LVS介绍 LVS实现 ldirectord

    Linux笔记 2018-07-01