docker-pull.sh.j2 424 B

123456789101112
  1. #!/bin/bash
  2. # {{ ansible_managed }}
  3. declare -a arr=({{ containers | map(attribute='name') | flatten | map('regex_replace', '^(.*)$', '"\\1"') | flatten | join(' ') }})
  4. for i in "${arr[@]}"; do
  5. output=$(docker{% if ansible_distribution_major_version|int == 9 %} {% else %}-{% endif %}compose -f /root/docker/$i/docker-compose.yml pull)
  6. if [[ $(echo $output | grep 'layers') ]]; then
  7. systemctl restart $i
  8. fi
  9. done