Skip to content

Instantly share code, notes, and snippets.

@kjelly
Created July 24, 2020 07:54
Show Gist options
  • Save kjelly/1c4d0f563204237f8e04433f201ef560 to your computer and use it in GitHub Desktop.
Save kjelly/1c4d0f563204237f8e04433f201ef560 to your computer and use it in GitHub Desktop.
restart docker container by ansible
- name: restart {{ service }}
hosts:
- "all"
gather_facts: no
tasks:
- name: Collect only facts returned by facter
setup:
filter: "ansible_date_time*"
gather_subset:
- '!all'
- '!any'
- facter
- shell: docker ps -a --format '{'{.Names}'}'|grep {{service}}|xargs docker restart
register: out
become: yes
- debug: var=out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment