我如何使用 ansible playbook 命令访问 gtm shell

How i can access gtm shell with ansible playbook command

我被卡住了,我可以很容易地为 GT.M 设置源,但是在此之后,当我启动 gtm 命令时它卡住了,也不要退出它,请有人帮助我。

我的代码如下:

---
- name: Copying files on local machine and printing Hello msg.
  hosts: webservers
  user: onkar
  remote_user: vistaehr
  gather_facts: False  
  #sudo: False
  tasks:  
    - name: copying local file
      copy: src=/home/onkar/onkar/Ansible/HELLO.m dest=/home/vistaehr/VistA/testr
      #shell: rm pwd.txt

    - name: Print Success
      debug: msg="success"

    - name: changing ownership of file
      #copy: src=/home/onkar/onkar/Ansible/HELLO.m dest=/home/vistaehr/VistA/testr
      shell: chown vistaehr:vistaehr /home/vistaehr/VistA/testr/HELLO.m

    - name: Setting Source        
      shell: . /home/vistaehr/VistA/env && gtm    

    - name: Print Success
      debug: msg="success"

    - name: zlinking given file      
      shell: zlink "/home/vistaehr/VistA/testr/HELLO.m"

gtm 启动一个控制台,它是一个交互过程。 Ansible 正在等待调用的命令退出。由于程序永远不会退出,您的 ansible 任务将永远不会完成。

你想通过从 Ansible 调用 gtm 来存档什么?如果您想启动一项服务,您应该查看 service 模块或查看 systemdinit.d,具体取决于您的系统。

运行一个命令gtm你可以用管道做:

echo 'zlink "/home/vistaehr/VistA/testr/HELLO.m"' | gtm

或者作为一个可靠的任务:

- name: Setting Source and zlinking given file
  shell: . /home/vistaehr/VistA/env && echo 'zlink "/home/vistaehr/VistA/testr/HELLO.m"' | gtm