【发布时间】:2021-05-25 06:03:41
【问题描述】:
我正在编写一个 ansible playbook 来执行各种 pm2 功能。
我搜索了一下,找不到有人设置 pm2-logrotate 的示例。
我相信我已经很接近了,但我不确定我的 shell 命令是否正常工作。当我 ssh 进入子节点并运行 sudo pm2 ls 时,它会显示 In-memory PM2 is out-of-date, do: $ pm2 update,即使我正在从我的剧本运行该命令。我在这里错过了什么?
---
# RUN playbook
# ansible-playbook -K pm2-setup.yml
- name: Setup pm2 and pm2-logrotate
hosts: devdebugs
remote_user: ansible
become: true
tasks:
- name: Install/Update pm2 globally
community.general.npm:
name: pm2
global: yes
state: latest
- name: Update In-memory pm2
ansible.builtin.shell: pm2 update
- name: Install/Update pm2-logrotate globally
ansible.builtin.shell: pm2 install pm2-logrotate
- name: Copy pm2-logrotate config
ansible.builtin.copy:
src: /home/ubuntu/files/pm2-logrotate-conf.json
dest: /home/ubuntu/.pm2/module_conf.json
owner: root
group: root
mode: '0644'
...
额外问题:有没有办法跳过不需要的 shell 命令(即如果 pm2-logrotate 已经安装)?
【问题讨论】: