Ansible playbook 问题

Ansible playbook 问题

我有一个剧本,它将从 git 中检出代码,将更改复制到相应的远程服务器并执行该过程,并将输出共享回 github,现在一切都很好,最后我需要重新启动服务器,但我的问题是它不应该是 root 用户,如何在使用普通用户访问权限的用户执行必要的更改后重新启动服务器,服务器是 weblogic,

---

- hosts: deploy
  tasks:

  - name: clone a private repository
    git:
      repo: '[email protected]:Rakshith/BELLCANNADA.git'
      dest: /srvrs/osm104/PONG
      version: SAAS_1
      clone: yes

  - copy:
          src=/srvrs/osm104/PONG/COM/OSM/OPERATION/OSM_104/wlst1.properties
          dest=/srvrs/osm104/Oracle/Middleware/Oracle_Home/oracle_common/common/bin/wlst1.properties
          mode=0644
          backup=true
          remote_src=yes


  - name: Execute script
    shell: wlst.sh >> OUTPUT.txt
    args:
      chdir: /srvrs/osm104/Oracle/Middleware/Oracle_Home/oracle_common/common/bin/
      creates: OUTPUT.txt


  - copy:
          src=/srvrs/osm104/Oracle/Middleware/Oracle_Home/oracle_common/common/bin/OUTPUT.txt
          dest=/srvrs/osm104/PONG/COM/OSM/OPERATION/OSM_104/SAAS1.0_OUTPUT_EnvName.txt
          mode=0644
          backup=true
          remote_src=yes


 - name: Reboot server
   shell: reboot
    become: yes
    become_user: some_user
    local_action: wait_for host="{{ 10.36.xx.xx }}" search_regex=OpenSSH port=22 timeout=300

答案1

也许添加一个处理程序?您需要在角色目录下创建一个处理程序文件。例如:roles/common/handlers/main.yml

- name: reboot server command: /sbin/reboot

相关内容