From 29fbf12b6291c9d251cc3fc5547f98d499c42cc3 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 15 Feb 2021 18:41:16 -0600 Subject: [PATCH] Set mfn up for using bash expressions in cron. --- facts/miner/gather.yml | 8 ++++++++ tasks/miner/acct_mgmt/users.yml | 1 + tasks/miner/cron/ansible.yml | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 facts/miner/gather.yml diff --git a/facts/miner/gather.yml b/facts/miner/gather.yml new file mode 100644 index 0000000..26dccf8 --- /dev/null +++ b/facts/miner/gather.yml @@ -0,0 +1,8 @@ +--- +# Find things we will use later. + +## Executables ## + +- name: Miner | Facts | System | Executables + shell: "which bash" + register: bash_exec \ No newline at end of file diff --git a/tasks/miner/acct_mgmt/users.yml b/tasks/miner/acct_mgmt/users.yml index d2fb7a1..39add90 100644 --- a/tasks/miner/acct_mgmt/users.yml +++ b/tasks/miner/acct_mgmt/users.yml @@ -19,4 +19,5 @@ - video - render append: yes + shell: "{{ bash_exec.stdout }}" register: user_mfn \ No newline at end of file diff --git a/tasks/miner/cron/ansible.yml b/tasks/miner/cron/ansible.yml index 82407e7..a79f31e 100644 --- a/tasks/miner/cron/ansible.yml +++ b/tasks/miner/cron/ansible.yml @@ -26,7 +26,7 @@ user: mfn name: "Start {{ item.name }}" minute: "*/5" - job: "ps -ef | grep '{{ item.command }}' | grep -v 'grep' && {{ item.command }}" + job: "[[ ps -ef | grep -v 'grep'| grep -c '{{ item.command }}' == '0' ]] && {{ item.command }}" state: present disabled: "{{ not(item.enabled) }}" loop: "{{ miners }}"