Ansible Test - Playbook-edit-file-execute

Ansible로 다중 서버의 환경구성 관리, 파일 관리를 최소한의 시간 + 자동화 + Human Error 0%로 처리하기

linux run.sh 수정 후 재실행하기

[오타 발생한 run.sh 파일]

#!/bin/bash
CURRENT_PID=$(pgrep -f wheet-core)
echo "$CURRENT_PID"
if [ -z $CURRENT_PID ]; then
    echo "> No process"
else
    echo "> kill -15 $CURRENT_PID"
    kill -15 $CURRENT_PID
    sleep 5
fi
chmod +x /usr/local/wheet-core-back/wheet-core.jar
nohup java -Xmx5512m -Xms5512m -XX:+UseParallelGC -jar -Dspring.profiles.active=wheet_sre /usr/local/wheet-core-back/wheet-core.jar &

run.sh 이 실행되어 오류가 발생한 상황
[Before]

[Inventory]

wheet-core1 ansible_host=172.22.3.109 ansible_ssh_pass=3w@@kWelcom ansible_user=ec2-user

[core-server]
wheet-core1

[api-core-edit-run-playbook.yml]

- name: update run.sh and execute
  hosts: core-servers
  tasks:
  - replace:
      path: /usr/local/wheet-core-back/run.sh
      regexp: 'nohup java -Xmx5512m -Xms5512m'
      replace: 'nohup java -Xmx512m -Xms512m'
  - name: execute run.sh
    shell: ./run.sh
    args:
      chdir: /usr/local/wheet-core-back

[Execution]

ansible-playbook api-core-edit-run-playbook.yml  -i inventory

[After]

좋은 웹페이지 즐겨찾기