Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Obsolete Cloneclean Cron Jobs on 'ptsupdate' #14

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions menu/roles/remove/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,41 @@
shell: 'apt-get purge snap -yqq 1>/dev/null 2>&1'
ignore_errors: yes

- name: Remove old Clone Clean Cron Job
cron:
name: Hourly Clean Clone Clean
state: absent
ignore_errors: yes

- name: Remove old Downloads Cleaner Cron Job
cron:
name: Hourly downloads cleaner
state: absent
ignore_errors: yes

- name: Get running processes list from remote host
ignore_errors: yes
shell: "ps -few | grep cloneclean | awk '{print $2}'"
register: running_processes

- name: Kill running processes
ignore_errors: yes
shell: "kill {{ item }}"
with_items: "{{ running_processes.stdout_lines }}"

- wait_for:
path: "/proc/{{ item }}/status"
state: absent
with_items: "{{ running_processes.stdout_lines }}"
ignore_errors: yes
register: cloneclean_processes

- name: Force kill stuck processes
ignore_errors: yes
shell: "kill -9 {{ item }}"
with_items: "{{ cloneclean_processes.results | select('failed') | map(attribute='item') | list }}"

- service:
name: cloneclean
state: restarted