我正在编写一个可操作的剧本来执行各种pm2功能。
我已经搜索了一点,但找不到有人设置PM2-log旋转的例子。
我相信我已经接近了,但我不确定我的shell命令是否有效。当我进入子节点并运行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日志旋转),是否有一种方法可以跳过shell命令?
发布于 2021-05-24 22:03:41
我把服务器上的用户搞混了。我通过指定update命令作为ubuntu运行来修正这个问题。
https://stackoverflow.com/questions/67442459
复制相似问题