aboutsummaryrefslogtreecommitdiff
path: root/tests/playbooks/pre.yml
blob: 01ded11b05779a9f54cdd398537a82cae2d8bfc9 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
- hosts: all
  vars_files:
    - ../vars/zuul.yml
  roles:
    - configure-ephemeral
  tasks:
    - name: Create dir for kolla logs
      file:
        path: "{{ kolla_logs_dir }}"
        state: directory

    - name: Dump host info to logs
      command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
      args:
        chdir: "{{ kolla_logs_dir }}"

    - name: Create dir for kolla build logs
      file:
        path: "{{ kolla_build_logs_dir }}"
        state: directory

    - name: Install Python3 pip and setuptools
      package:
        name:
          - python3-pip
          - python3-setuptools
      become: true

    # NOTE(hrw): On RedHat systems venv is part of python3-libs
    - name: Install Python3 venv on Debian systems
      package:
        name:
          - python3-venv
      become: true
      when:
        ansible_os_family == "Debian"

    - name: Create virtualenv
      command: python3 -m venv {{ virtualenv_path }}

    - name: Install kolla
      command: "{{ virtualenv_path }}/bin/python -m pip install {{ zuul.project.src_dir }}"

    - name: Install podman python library
      command: "{{ virtualenv_path }}/bin/python -m pip install podman"
      when: container_engine == "podman"

    - name: Configure Docker repo for Debian/Ubuntu
      block:
        - name: Add key for Docker APT repository
          apt_key:
            url: "{{ nodepool_docker_proxy }}/{{ ansible_distribution | lower }}/gpg"
            state: present

        - name: Add Docker APT repository
          apt_repository:
            repo: "deb {{ nodepool_docker_proxy }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
            state: present

        - name: Ensure AppArmor is installed
          package:
            name: apparmor
            state: present

      when:
        - ansible_os_family == "Debian"
        - container_engine == "docker"
      become: true

    - name: Configure Docker repo for CentOS
      block:
        - name: Add Docker repository
          yum_repository:
            name: docker
            description: Docker
            baseurl: "{{ nodepool_docker_proxy }}/centos/9/$basearch/stable"
            enabled: yes
            gpgcheck: yes
            gpgkey: "{{ nodepool_docker_proxy }}/centos/gpg"
            # module_hotfixes: True  # enabled below (dnf, not yum, feature)

        - name: Enable module_hotfixes in Docker YUM repository
          lineinfile:
            path: /etc/yum.repos.d/docker.repo
            line: 'module_hotfixes=True'
      when:
        - ansible_os_family == "RedHat"
        - container_engine == "docker"
      become: true

    - name: Configure docker
      block:
        - name: Ensure /etc/docker exists
          become: true
          file:
            path: /etc/docker
            state: directory
            mode: 0755

        - name: Configure registry-mirror in daemon.json
          become: true
          copy:
            dest: /etc/docker/daemon.json
            content: |
              {
                "registry-mirrors": [
                  "http://{{ zuul_site_mirror_fqdn }}:8082/"
                ]
              }

        # NOTE(yoctozepto): We configure Docker before installing it because Debuntu starts services
        # during installation.
        - name: Install Docker
          package:
            name: docker-ce
          become: true

        - name: Ensure Docker service is started
          service:
            name: docker
            state: started
          become: true

        - name: Ensure Docker socket is world-writable
          file:
            path: /run/docker.sock
            mode: 0666
          become: true
      when:
        - container_engine == "docker"

    - name: Configure podman
      block:
        - name: Ensure /etc/containers exists
          become: true
          file:
            path: /etc/containers
            state: directory
            mode: 0755

        - name: Configure registries.conf
          become: true
          copy:
            dest: /etc/containers/registries.conf
            content: |
              unqualified-search-registries = ['docker.io']

              [[registry]]
              prefix = "docker.io"
              location = "docker.io"

              [[registry.mirror]]
              prefix = "docker.io"
              location = "{{ zuul_site_mirror_fqdn }}:8082"

        - name: Install Podman
          package:
            name: podman
          become: true

        # NOTE(jangutter): It appears that the default mount option
        # in the shipped `/etc/containers/storage.conf` for EL9 based distros
        # (Rocky, CentOS Stream, ...) has severe performance implications for
        # Kolla builds. This is because enabling `metacopy=on` disables `Native
        # Overlay Diff` This can be removed if the config is dropped from those
        # distros, or the underlying incompatibility can somehow be addressed.
        # Debian based distros do not ship `storage.conf` and seem
        # to be unaffected.
        - name: Remove metacopy, enable native overlay diff
          ini_file:
            path: /etc/containers/storage.conf
            section: storage.options.overlay
            option: mountopt
            value: '"nodev"'
          become: true
          when: ansible_os_family == "RedHat"

        - name: Ensure Podman service is started
          service:
            name: podman
            state: started
          become: true

        - name: Ensure Podman socket is world-writable
          file:
            path: /run/podman/podman.sock
            mode: 0666
          become: true
      when:
        - container_engine == "podman"