# ansible 初始化服务机
- hosts: newserver
vars:
- basedir: opt
tasks:
- name: 安装常用依赖环境
yum: name={{ item }} state=present
with_items:
- lrzsz
- telnet
- wget
- epel-release - name: 为所有创建的新用户添加属组
group:
name: develop
state: present
- name: 将yutang用户加入develop组
shell: usermod -G develop yutang - name: 创建微服务基本运行父级目录环境
file: path=/{{ basedir }}/{{ item }}/ state=directory owner=test group=develop mode=0755
with_items:
- service
- server
- src - name: 创建微服务基本运行子级server目录环境
file: path=/{{ basedir }}/server/{{ item }}/ state=directory owner=test group=develop mode=0755
with_items:
- backup
- config - name: 创建微服务基本运行子级service目录环境
file: path=/{{ basedir }}/service/{{ item }}/ state=directory owner=yutang group=develop mode=0755
with_items:
- tmp
- logs - name: 下载jdk环境
get_url: url=http://mirror.cnop.net/jdk/linux/jdk-8u112-linux-x64.tar.gz dest=/{{ basedir }}/server/src mode=0655 force=yes owner=test
- name: 解压jdk压缩包
unarchive: src=/{{ basedir }}/server/src/jdk-8u112-linux-x64.tar.gz dest=/{{ basedir }}/server/ mode=0755 copy=no - name: 添加jdk环境变量
lineinfile: dest=/etc/profile line="export JAVA_HOME=/opt/server/jdk1.8.0_112" - name: 添加jdk环境变量
lineinfile: dest=/etc/profile line="export PATH=$JAVA_HOME/bin:$PATH" - name: 将本地logstash文件传输到远程服务器
copy: src=/{{ basedir }}/server/logstash.tar.gz dest=/{{ basedir }}/server/ owner=test group=develop mode=0755 - name: 解压logstash压缩包
unarchive: src=/{{ basedir }}/server/logstash.tar.gz dest=/{{ basedir }}/server/ mode=0755 owner=test group=develop copy=no - name: 将本地pinpoint文件传输到远程服务器
copy: src=/{{ basedir }}/server/pinpoint-agent.tar.gz dest=/{{ basedir }}/server/ owner=test group=develop mode=0755 - name: 解压pinpoint压缩包
unarchive: src=/{{ basedir }}/server/pinpoint-agent.tar.gz dest=/{{ basedir }}/service/ mode=0755 owner=test group=develop copy=no - name: 将本地consul文件传输到远程服务器
copy: src=/{{ basedir }}/server/consul.tar.gz dest=/{{ basedir }}/server/ owner=test group=develop mode=0755 - name: 解压consul压缩包
unarchive: src=/{{ basedir }}/server/consul.tar.gz dest=/{{ basedir }}/server/ mode=0755 owner=test group=develop copy=no - name: 移动config.tar.gz和ogstash.tar.gz到/alidata/server/download备份目录下
shell: /usr/bin/mv /{{ basedir }}/server/*.gz /{{ basedir }}/server/download/ - name: 授权所有目录权限为yutang
shell: chown -R test.develop /{{ basedir }} - name: 修改主机名
raw: "echo {{hostname|quote}} > /etc/hostname" - name: 设置主机名
shell: hostname {{hostname|quote}} - name: 刷新java环境变量
shell: source /etc/profile - name: 定时清理系统缓存
cron: name="每隔1小时清理一次系统缓存" job="/usr/bin/sync; /usr/bin/echo 3 > /proc/sys/vm/drop_caches" minute=*/60 state=present

ansible publishing service的更多相关文章

  1. Ansible笔记(7)---常用模块之系统类模块(cron、service)

    一.cron模块 1.1作用: cron 模块可以帮助我们管理远程主机中的计划任务,功能相当于 crontab 命令. 在了解cron模块的参数之前,先写出一些计划任务的示例: # 示例1,每天的1点 ...

  2. 对ansible不支持service模块的status命令进行修正

    原生的ansible不支持service.status,在Google之后,发现有人提交了一个patch,可以支持status选项.见https://github.com/ritzk/ansible- ...

  3. ansible的使用技巧

    #查看ansible的帮助 $ ansible -h   #ansible 指定不通的模块执行 $ ansible -i /etc/ansible/hosts  docker -u root -m c ...

  4. ansible 安装使用

    ansible ansible源码安装 yum -y install python-jinja2 PyPAML python-parmiko python-babel python-crypto ta ...

  5. 除非 Windows Activation Service (WAS)和万维网发布服务(W3SVC)均处于运行状态,否则无法启动网站。目前,这两项服务均处于停止状态。

    win7 IIS 所有网站都停止了,启动提示: 除非 Windows Activation Service (WAS)和万维网发布服务(W3SVC)均处于运行状态,否则无法启动网站.目前,这两项服务均 ...

  6. IIS Default Web Site : The service did not response to the start or control request in a timely fashion

    IIS Default Web Site无法启动,提示错误:The service did not response to the start or control request in a time ...

  7. Ansible 系列之 Ad-Hoc介绍及使用

    Ad-Hoc 介绍 一.什么是ad-hoc 命令? ad-hoc 命令是一种可以快速输入的命令,而且不需要保存起来的命令.就相当于bash中的一句话shell.这也是一个好的地方,在学习ansible ...

  8. Windows 下 exe 服务注册到 service 服务中

    window 下注册 exe 程序.添加到 服务中. window 注册服务方式 一. regsvr 方式 直接在 程序目录执行: Regsvr 32 命令是Windows中控件文件 ( 如扩展名为D ...

  9. ansible学习笔记二

    Ad-Hoc命令: 所谓Ad-Hoc,简而言之是"临时命令",英文中作为形容词有"特别的,临时"的含义.Ad-Hoc只是官方对Ansible命令的一种称谓. 从 ...

随机推荐

  1. spring cloud feign 坑

    feign是啥? 很多人可能对于feign 不是很熟悉,可以看一下其他网友的实例分享:spring cloud feign简介 如果觉得上面这个比较难的话,还有一个简单入门的:spring cplou ...

  2. 54. spring boot日志升级篇—logback【从零开始学Spring Boot】

    在<44. Spring Boot日志记录SLF4J>章节中有关相关的介绍,这里我们在深入的了解下logback框架. 为什么要使用logback ? --在开发中不建议使用System. ...

  3. 矩形面积求并(codevs 3044)

    题目描述 Description 输入n个矩形,求他们总共占地面积(也就是求一下面积的并) 输入描述 Input Description 可能有多组数据,读到n=0为止(不超过15组) 每组数据第一行 ...

  4. Ubuntu安装vnc 解决乱码

    https://blog.csdn.net/dddxxxx/article/details/53580789 https://www.centos.bz/2017/12/%E8%A7%A3%E5%86 ...

  5. HDU1026 Ignatius and the Princess I 【BFS】+【路径记录】

    Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  6. 【转】gcov lcov 覆盖c/c++项目入门

    原文: http://www.cnblogs.com/turtle-fly/archive/2013/01/09/2851474.html ------------------------------ ...

  7. Andriod开发技巧——Fragment的懒载入

    我们在做应用开发的时候.一个Activity里面可能会以viewpager(或其它容器)与多个Fragment来组合使用.而假设每一个fragment都须要去载入数据.或从本地载入.或从网络载入,那么 ...

  8. 转 java synchronized详解

    转自 http://www.cnblogs.com/GnagWang/archive/2011/02/27/1966606.html Java语言的关键字,当它用来修饰一个方法或者一个代码块的时候,能 ...

  9. 数学之路-python计算实战(17)-机器视觉-滤波去噪(中值滤波)

    Blurs an image using the median filter. C++: void medianBlur(InputArray src, OutputArray dst, int ks ...

  10. 【C语言】模拟实现memmove函数(考虑内存重叠)

    //模拟实现memmove函数(考虑内存重叠) #include <stdio.h> #include <assert.h> #include <string.h> ...