linux - pm2 log-rotate with ansible

标签 linux ubuntu ansible pm2

我正在编写一个 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/

相关文章:

linux - 我怎样才能将文件名保存为这段代码的变量

linux - bash ubuntu linux 中的脚本程序输入

ansible - 显示警告 "conditional statements should not include jinja2 templating delimiters”

Ansible使用密码创建用户,如果用户存在则不要更改它

linux - 如何使用 Bash(sed 或任何其他)命令在第 EOF-n 行插入

linux - RabbitMQ Shovel 无法启动

linux - 找不到变量 : loadFixtures

linux - Apache2 运行 perl 脚本作为目录索引

android - 尝试在 Ubuntu 13.04 上运行 Phonegap

regex - 使用 insertafter 的 Ansible lineinfile 复制