freehck.script_with_locks

freehck.script_with_locks

这个角色复制一个可以在指定锁下运行任何命令的脚本。

对于定时任务(crontab)非常有用。运行命令 --help 可以了解更多选项。

角色变量

with_locks_script_dir:安装脚本的目录,默认是 "/opt/scripts"

with_locks_script_name:脚本名称,默认是 "with-locks"

with_locks_install_deps:安装依赖(moreutils),默认是 "yes"

示例剧本

- hosts:
    - database
  become: yes
  vars:
    lockfile: "/var/lock/db-update-index.lock"
    logfile: "/var/log/db-update-index.log"
  roles:
    - role: freehck.script_with_locks
    - role: freehck.crontask
      crontask_file: "database"
      crontask_name: "更新索引"
      crontask_minute: "*/30"
      crontask_user: "root"
      crontask_job: "/opt/scripts/with-locks --timestamp --pid --highlight-errors --silent --lock {{ lockfile }} --log {{ logfile }} -- /opt/scripts/perform_update_index.sh"
      # 或者没有长选项的版本:
      # crontask_job: "/opt/scripts/with-locks -tpes -l {{ lockfile }} -j {{ logfile }} -- /opt/scripts/perform_update_index.sh"

许可证

MIT

作者信息

Dmitrii Kashin, freehck@freehck.ru

关于项目

create a script that allows to run commands with locks

安装
ansible-galaxy install freehck.script_with_locks
许可证
mit
下载
2k
拥有者