我正在编写一个 ansible 剧本来执行各种 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'
...
额外的问题:如果不需要它们(即如果已经安装了 pm2-logrotate),有没有办法跳过 shell 命令?
最佳答案
我在我的服务器上混淆了用户。我通过指定作为更新命令的 ubuntu 运行来解决此问题。
关于linux - pm2 log-rotate with ansible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67442459/