Last active
September 26, 2018 17:49
-
-
Save mwhahaha/2f8029d04a6f27b9edaf6d6d4e9fd2e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Async pull images from remote mirror and push into local registry | |
docker_image: | |
name: "{{ async_item.imagename }}" | |
repository: "localhost:8787/{{ async_item.imagename | regex_replace('docker.io/') }}" | |
push: yes | |
debug: yes | |
async: 1500 | |
poll: 0 | |
loop: "{{ images }}" | |
loop_control: | |
loop_var: "async_item" | |
register: async_results | |
- name: async_result output? | |
debug: | |
var: async_results | |
- name: Check sync status | |
async_status: | |
jid: "{{ async_result_item.ansible_job_id }}" | |
loop: "{{ async_results.results }}" | |
loop_control: | |
loop_var: "async_result_item" | |
register: async_poll_results | |
until: async_poll_results.finished | |
retries: 30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
hosts: | |
primary: | |
ansible_connection: local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: primary | |
become: true | |
tasks: | |
- name: Deploy Docker | |
include_role: | |
name: ansible-role-container-registry | |
tasks_from: docker | |
vars: | |
# container_registry_mirror: "http://{{ zuul_site_mirror_fqdn }}:8081/registry-1.docker/" | |
container_registry_debug: true | |
container_registry_insecure_registries: ['localhost:8787'] | |
- name: Deploy a Docker Registry v2 | |
include_role: | |
name: ansible-role-container-registry | |
tasks_from: docker-distribution | |
- meta: flush_handlers | |
- name: Collect Docker config | |
shell: | |
docker info | |
register: docker_info | |
- name: Display Docker config | |
debug: msg={{ docker_info.stdout_lines|list }} | |
- name: Check for local containers list | |
stat: | |
path: /home/zuul/src/git.openstack.org/openstack/tripleo-common/container-images/overcloud_containers.yaml | |
register: local_container_file | |
- block: | |
- name: Grab containers list from host | |
slurp: | |
src: /home/zuul/src/git.openstack.org/openstack/tripleo-common/container-images/overcloud_containers.yaml | |
register: container_list | |
when: local_container_file.stat.exists | |
- block: | |
- name: Build container_url | |
set_fact: | |
container_url: "http://git.openstack.org/cgit/openstack/tripleo-common/plain/container-images/overcloud_containers.yaml?h=master" | |
- name: Create temporary file | |
tempfile: | |
state: file | |
suffix: containers | |
register: temp_containers_file | |
- name: Fetch url | |
get_url: | |
url: "{{ container_url }}" | |
dest: "{{ temp_containers_file.path }}" | |
force: True | |
- name: Get containers data | |
slurp: | |
src: "{{ temp_containers_file.path }}" | |
register: container_list | |
- name: Cleanup temp file | |
file: | |
path: "{{ temp_containers_file.path }}" | |
state: absent | |
when: not local_container_file.stat.exists | |
- name: Print container list file data | |
debug: msg={{ container_list['content'] | b64decode }} | |
- name: Set container_image_data | |
set_fact: | |
container_image_data: "{{ container_list['content'] | b64decode | from_yaml }}" | |
- name: Print container_image_data | |
debug: var=container_image_data | |
- name: Install the latest version of python-docker-py required by ansible | |
yum: | |
name: python-docker-py | |
state: latest | |
- name: Pull images from remote mirror and push into local registry | |
vars: | |
container_images: "{{ container_image_data.container_images }}" | |
images: "{{ item }}" | |
include_tasks: async-container-fetch.yaml | |
loop: "{{ container_image_data.container_images | batch(10) | list}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment