summaryrefslogtreecommitdiffstats
path: root/lib/ansible/playbooks/prepare_overcloud_containers.yml
blob: 79629c2bf38428f89f53e2c6d9a69beb97347877 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
- hosts: all
  tasks:
    - name: Upload container patches archive
      copy:
        src: "{{ apex_temp_dir }}/docker_patches.tar.gz"
        dest: "/home/stack/docker_patches.tar.gz"
        owner: stack
        group: stack
        mode: 0644
      when: patched_docker_services|length > 0
    - name: Unpack container patches archive
      unarchive:
        src: /home/stack/docker_patches.tar.gz
        remote_src: yes
        list_files: yes
        group: stack
        owner: stack
        dest: /home/stack/
      when: patched_docker_services|length > 0
    - name: Prepare generic docker registry image file
      shell: >
        {{ stackrc }} && openstack overcloud container image prepare
        --namespace docker.io/tripleo{{ os_version }}
        --tag {{ container_tag }}
        --push-destination {{ undercloud_ip }}:8787
        -e /usr/share/openstack-tripleo-heat-templates/environments/docker.yaml
        --output-images-file overcloud_containers.yml
      become: yes
      become_user: stack
    - name: Prepare SDN docker registry image file
      shell: >
        {{ stackrc }} && openstack overcloud container image prepare
        --namespace docker.io/tripleo{{ os_version }}
        --tag {{ container_tag }}
        --push-destination {{ undercloud_ip }}:8787
        -e {{ sdn_env_file }}
        --output-images-file sdn_containers.yml
      become: yes
      become_user: stack
      when: sdn != false
    - name: Upload docker images to local registry
      shell: >
        {{ stackrc }} && openstack overcloud container image upload
        --config-file /home/stack/overcloud_containers.yml
    - name: Upload SDN docker images to local registry
      shell: >
        {{ stackrc }} && openstack overcloud container image upload
        --config-file /home/stack/sdn_containers.yml
      when: sdn != false
    - name: Collect docker images in registry
      uri:
        url: http://{{ undercloud_ip }}:8787/v2/_catalog
        body_format: json
      register: response
    - name: Patch Docker images
      shell: >
        cd /home/stack/containers/{{ item }} && docker build
        -t {{ undercloud_ip }}:8787/tripleo{{ os_version }}/centos-binary-{{ item }}:apex .
      when:
        - patched_docker_services|length > 0
        - item in (response.json)['repositories']|join(" ")
      with_items: "{{ patched_docker_services }}"
    - name: Push patched docker images to local registry
      shell: docker push {{ undercloud_ip }}:8787/tripleo{{ os_version }}/centos-binary-{{ item }}:apex
      when:
        - patched_docker_services|length > 0
        - item in (response.json)['repositories']|join(" ")
      with_items: "{{ patched_docker_services }}"
    - name: Prepare deployment generic docker image file
      shell: >
        {{ stackrc }} && openstack overcloud container image prepare
        --namespace {{ undercloud_ip }}:8787/tripleo{{ os_version }}
        --tag {{ container_tag }}
        -e /usr/share/openstack-tripleo-heat-templates/environments/docker.yaml
        --output-env-file docker-images.yaml
      become: yes
      become_user: stack
    - name: Prepare deployment SDN docker image file
      shell: >
        {{ stackrc }} && openstack overcloud container image prepare
        --namespace {{ undercloud_ip }}:8787/tripleo{{ os_version }}
        --tag {{ container_tag }}
        -e {{ sdn_env_file }}
        --output-env-file sdn-images.yaml
      when: sdn != false
      become: yes
      become_user: stack
    - name: Modify Images with Apex tag
      replace:
        path: "{{ item[0] }}"
        regexp: "(\\s*Docker.*?:.*?centos-binary-{{ item[1] }}):.*"
        replace: '\1:apex'
      with_nested:
        - [ '/home/stack/sdn-images.yaml', '/home/stack/docker-images.yaml']
        - "{{ patched_docker_services }}"
    - name: Pull Ceph docker image
      shell: docker pull {{ ceph_docker_image }}
      become: yes
    - name: Tag Ceph image for local registry
      shell: docker tag {{ ceph_docker_image }} {{ undercloud_ip }}:8787/{{ ceph_docker_image }}
      become: yes
    - name: Push Ceph docker image to local registry
      shell: docker push {{ undercloud_ip }}:8787/{{ ceph_docker_image }}
      become: yes