标签:col with download java环境 远程服务器 profile 刷新 文件 用户
1 # ansible 初始化服务机 2 - hosts: newserver 3 vars: 4 - basedir: opt 5 tasks: 6 - name: 安装常用依赖环境 7 yum: name={{ item }} state=present 8 with_items: 9 - lrzsz 10 - telnet 11 - wget 12 - epel-release 13 14 - name: 为所有创建的新用户添加属组 15 group: 16 name: develop 17 state: present 18 - name: 将yutang用户加入develop组 19 shell: usermod -G develop yutang 20 21 - name: 创建微服务基本运行父级目录环境 22 file: path=/{{ basedir }}/{{ item }}/ state=directory owner=test group=develop mode=0755 23 with_items: 24 - service 25 - server 26 - src 27 28 - name: 创建微服务基本运行子级server目录环境 29 file: path=/{{ basedir }}/server/{{ item }}/ state=directory owner=test group=develop mode=0755 30 with_items: 31 - backup 32 - config 33 34 - name: 创建微服务基本运行子级service目录环境 35 file: path=/{{ basedir }}/service/{{ item }}/ state=directory owner=yutang group=develop mode=0755 36 with_items: 37 - tmp 38 - logs 39 40 - name: 下载jdk环境 41 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 42 - name: 解压jdk压缩包 43 unarchive: src=/{{ basedir }}/server/src/jdk-8u112-linux-x64.tar.gz dest=/{{ basedir }}/server/ mode=0755 copy=no 44 45 - name: 添加jdk环境变量 46 lineinfile: dest=/etc/profile line="export JAVA_HOME=/opt/server/jdk1.8.0_112" 47 48 - name: 添加jdk环境变量 49 lineinfile: dest=/etc/profile line="export PATH=$JAVA_HOME/bin:$PATH" 50 51 52 - name: 将本地logstash文件传输到远程服务器 53 copy: src=/{{ basedir }}/server/logstash.tar.gz dest=/{{ basedir }}/server/ owner=test group=develop mode=0755 54 55 - name: 解压logstash压缩包 56 unarchive: src=/{{ basedir }}/server/logstash.tar.gz dest=/{{ basedir }}/server/ mode=0755 owner=test group=develop copy=no 57 58 - name: 将本地pinpoint文件传输到远程服务器 59 copy: src=/{{ basedir }}/server/pinpoint-agent.tar.gz dest=/{{ basedir }}/server/ owner=test group=develop mode=0755 60 61 - name: 解压pinpoint压缩包 62 unarchive: src=/{{ basedir }}/server/pinpoint-agent.tar.gz dest=/{{ basedir }}/service/ mode=0755 owner=test group=develop copy=no 63 64 - name: 将本地consul文件传输到远程服务器 65 copy: src=/{{ basedir }}/server/consul.tar.gz dest=/{{ basedir }}/server/ owner=test group=develop mode=0755 66 67 - name: 解压consul压缩包 68 unarchive: src=/{{ basedir }}/server/consul.tar.gz dest=/{{ basedir }}/server/ mode=0755 owner=test group=develop copy=no 69 70 71 - name: 移动config.tar.gz和ogstash.tar.gz到/alidata/server/download备份目录下 72 shell: /usr/bin/mv /{{ basedir }}/server/*.gz /{{ basedir }}/server/download/ 73 74 - name: 授权所有目录权限为yutang 75 shell: chown -R test.develop /{{ basedir }} 76 77 78 - name: 修改主机名 79 raw: "echo {{hostname|quote}} > /etc/hostname" 80 81 - name: 设置主机名 82 shell: hostname {{hostname|quote}} 83 84 - name: 刷新java环境变量 85 shell: source /etc/profile 86 87 - name: 定时清理系统缓存 88 cron: name="每隔1小时清理一次系统缓存" job="/usr/bin/sync; /usr/bin/echo 3 > /proc/sys/vm/drop_caches" minute=*/60 state=present
标签:col with download java环境 远程服务器 profile 刷新 文件 用户
原文地址:https://www.cnblogs.com/ipyanthony/p/10969958.html