freehck.script_with_locks
freehck.script_with_locks
この役割は、指定されたロックで任意のコマンドを実行するスクリプトをコピーします。
クロンジョブに非常に便利です。オプションを知るために --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