Skip to content
Snippets Groups Projects
run.yml 13.81 KiB
---
- hosts: all
  tasks:
    # NOTE(yoctozepto): ensure we pick up fact changes from pre
    - name: Refresh facts
      setup:

    # NOTE(yoctozepto): setting vars as facts for all to have them around in all the plays
    - name: set facts for commonly used variables
      set_fact:
        kolla_inventory_path: "/etc/kolla/inventory"
        logs_dir: "/tmp/logs"
        kolla_ansible_src_dir: "{{ ansible_env.PWD }}/src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
        kolla_ansible_local_src_dir: "{{ zuul.executor.work_root }}/src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
        need_build_image: false
        build_image_tag: "change_{{ zuul.change | default('none') }}"
        is_upgrade: "{{ 'upgrade' in scenario }}"
        is_ceph: "{{ 'ceph' in scenario }}"
        primary_address: "{{ hostvars.primary['ansible_' + api_interface_name].ipv4.address }}"

    - name: Prepare disks for Ceph or LVM
      script: "setup_disks.sh {{ disk_type }}"
      when: scenario == "cinder-lvm" or is_ceph
      become: true
      vars:
        disk_type: "{{ ceph_storetype if is_ceph else 'cinder-lvm' }}"
        ceph_storetype: "{{ hostvars[inventory_hostname].get('ceph_osd_storetype') }}"

- hosts: primary
  tasks:
    - name: detect whether need build images
      set_fact:
        need_build_image: true
      when:
        - item.project.short_name == "kolla"
        - item.branch == zuul.branch
      with_items: "{{ zuul['items'] }}"

    # NOTE(yoctozepto): required to template template_overrides.j2 for Zuul
    - name: Include kolla Zuul vars if building new images
      include_vars:
        file: "{{ zuul.executor.work_root }}/src/opendev.org/openstack/kolla/tests/vars/zuul.yml"
      when: need_build_image  # only then kolla sources are available (and used)

    # NOTE(mgoddard): This only affects the remote copy of the repo, not the
    # one on the executor.
    - name: checkout the previous kolla-ansible branch
      shell:
        cmd: |
          git checkout stable/{{ previous_release | lower }}
          echo "kolla-ansible checked out to:"
          git log --pretty=oneline  -1
        chdir: "{{ kolla_ansible_src_dir }}"
      when: is_upgrade

    - name: ensure /etc/kolla exists
      file:
        path: "/etc/kolla"
        state: "directory"
        mode: 0777
      become: true

    # NOTE(yoctozepto): required to customize kolla to use local mirrors
    - name: Template template_overrides.j2
      template:
        src: "{{ zuul.executor.work_root }}/src/opendev.org/openstack/kolla/tests/templates/template_overrides.j2"
        dest: /etc/kolla/template_overrides.j2
      when: need_build_image  # only then kolla sources are available (and used)

    - name: Ensure /etc/docker exists