http://docs.ansible.com/ansible/lineinfile_module.html
---
#拷贝console安装包
- name: upload console package
copy: src={{console_des.pkg_dir}}/{{console_des.pkg_name_head}}-{{console_target_partner}}-{{version}}-{{console_des.pkg_name_tail}} dest={{common.build_dir}} force=yes
- name: add onframework sudo no password
lineinfile: dest={{common.etc_sudoer_path}} regexp='^des ALL=NOPASSWD:ALL' line='des ALL=NOPASSWD:ALL'
sudo: yes
- name: remove dir
shell: 'rm -rf {{console_des.install_dir}}'
sudo: yes
#解压console-home安装包
- name: untar
unarchive: src={{common.build_dir}}/{{console_des.pkg_name_head}}-{{console_target_partner}}-{{version}}-{{console_des.pkg_name_tail}} dest={{console_des.untar_dir}} copy=no
#配置安装配置文件
- name: config user
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.user=' line='service.user={{common.system_user}}'
- name: config group
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.user.group=' line='service.user.group={{common.system_group}}'
- name: config iam ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.iam\.ip=' line='service.iam.ip={{iam_info.ip}}'
- name: config iam authui port
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.iam\.authui\.port=' line='service.iam.authui.port={{iam_info.port}}'
- name: config iam server port
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.iam\.server\.port=' line='service.iam.server.port={{iam_info.port}}'
- name: config iam outer address
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.iam\.outer\.address=' line='service.iam.outer.address={{iam_outer_address}}'
- name: config memcache ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.memcache\.ip=' line='service.memcache.ip={{g_console.memcached.address}}'
- name: config silvan ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.silvan\.ip=' line='service.silvan.ip={{silvan.ip}}'
- name: config silvan port
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.silvan\.port=' line='service.silvan.port={{silvan.port}}'
- name: config webapp address when lb on
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.webapp\.address=' line='service.webapp.address=https://{{console_address}}/des/'
- name: config old console webapp address
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.oldconsole\.address=' line='service.oldconsole.address={{old_console.address}}'
- name: config static file server
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^static\.service\.address=' line='static.service.address={{static_server_address}}'
- name: config webapp name
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.webapp\.name=' line='service.webapp.name=des'
- name: config tomcat path
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^tomcat\.path=' line='tomcat.path={{tomcat.install_dir}}'
- name: config uds ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.uds\.ip=' line='service.uds.ip={{ip.uds.ip}}'
- name: config uds region
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.uds\.region=' line='service.uds.region={{ip.uds.region}}'
- name: config upload ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.upload\.ip=' line='service.upload.ip={{ip.upload}}'
- name: config gauss ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.gauss\.ip=' line='service.gauss.ip={{ip.gauss}}'
- name: config smn ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.smn\.ip=' line='service.smn.ip={{smn.ip}}'
- name: config smn port
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.smn\.port=' line='service.smn.port={{smn.port}}'
- name: config bss ip
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.bss\.ip=' line='service.bss.ip={{bss.ip}}'
when: bss.ip | trim != ""
- name: config bss port
lineinfile: dest={{console_des.make_dir}}/console.conf regexp='^service\.bss\.port=' line='service.bss.port={{bss.port}}'
when: bss.port | trim != ""
#上传证书
- name: replace certificate
shell: 'cp iamKeyStore.jks {{console_des.config_dir}}'
args:
chdir: '{{common.build_dir}}'
#dos2unix安装、启停脚本
- name: dos2unix console conf
shell: dos2unix {{console_des.make_dir}}/*
- name: dos2unix bin shell
shell: dos2unix {{console_des.bin_dir}}/*
#添加安装脚本执行权限
- name: add install shell execute right
file: path={{console_des.make_dir}}/console_install.sh mode=u+x
- name: install
shell: '{{console_des.make_dir}}/console_install.sh'
#启动console-home
- name: start
shell: 'nohup sh tomcat_monitor.sh restart'
args:
chdir: '{{console_des.bin_dir}}'
#删除console安装包
- name: remove console build package
file: path={{common.build_dir}}/{{console_des.pkg_name_head}}-{{console_target_partner}}-{{version}}-{{console_des.pkg_name_tail}} state=absent
- name: remove onframework sudo no password
lineinfile: dest={{common.etc_sudoer_path}} regexp='^des ALL=NOPASSWD:ALL' state=absent
sudo: yes
- name: print msg
debug: msg="Upgrade DESConsole-{{version}} succ. Current date and time is {{ansible_date_time.date}} {{ansible_date_time.time}}"