Skip to content
Snippets Groups Projects
run.yml 7.15 KiB
Newer Older
- hosts: all
  vars:
    kolla_ansible_src_dir: "src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
    kolla_ansible_full_src_dir: "{{ zuul.executor.work_root }}/{{ kolla_ansible_src_dir }}"
  tasks:
    - name: Prepare ceph disks
      script: "{{ kolla_ansible_full_src_dir }}/tests/setup_ceph_disks.sh"
      when: scenario == "ceph"
      become: true

  vars:
    kolla_inventory_path: "/etc/kolla/inventory"
    logs_dir: "/tmp/logs"
Jeffrey Zhang's avatar
Jeffrey Zhang committed
    kolla_ansible_src_dir: "src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
    kolla_ansible_full_src_dir: "{{ zuul.executor.work_root }}/{{ kolla_ansible_src_dir }}"
  tasks:
    - name: ensure /etc/kolla exists
      file:
        path: "/etc/kolla"
        state: "directory"
        mode: 0777
      become: true

    - name: copy default ansible kolla-ansible inventory
        src: "{{ kolla_ansible_full_src_dir }}/tests/templates/inventory.j2"
        dest: "{{ kolla_inventory_path }}"
      delegate_to: "primary"

Jeffrey Zhang's avatar
Jeffrey Zhang committed
    # FIXME: in multi node env, api_interface may be different on each node.
    - name: detect api_interface_name variable
Jeffrey Zhang's avatar
Jeffrey Zhang committed
        ansible_interface_name: "ansible_{{ item.replace('-', '_') }}"
        api_interface_address: "{{ hostvars[inventory_hostname]['nodepool']['private_ipv4'] }}"
      set_fact:
        api_interface_name: "{{ item }}"
        api_interface_address: "{{ api_interface_address }}"
      when:
        - hostvars[inventory_hostname][ansible_interface_name]['ipv4'] is defined
        - hostvars[inventory_hostname][ansible_interface_name]['ipv4']['address'] == api_interface_address
      with_items: "{{ ansible_interfaces }}"
      delegate_to: "primary"

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

Jeffrey Zhang's avatar
Jeffrey Zhang committed
    - name: generate global.yml file
      template:
Jeffrey Zhang's avatar
Jeffrey Zhang committed
        src: "{{ kolla_ansible_full_src_dir }}/tests/templates/globals-default.j2"
        dest: /etc/kolla/globals.yml
      delegate_to: "primary"

    - name: ensure nova conf overrides dir exists
      file:
        path: "/etc/kolla/config/nova"
        state: "directory"
        mode: 0777
      when: scenario != "bifrost"
      become: true
      delegate_to: "primary"

    - name: generate nova config overrides
      template:
Jeffrey Zhang's avatar
Jeffrey Zhang committed
        src: "{{ kolla_ansible_full_src_dir }}/tests/templates/nova-compute-overrides.j2"
        dest: /etc/kolla/config/nova/nova-compute.conf
      when: scenario != "bifrost"
      delegate_to: "primary"

    - name: ensure bifrost conf overrides dir exists
      file:
        path: "/etc/kolla/config/bifrost"
        state: "directory"
        mode: 0777
      when: scenario == "bifrost"
      become: true
      delegate_to: "primary"

    - name: generate bifrost DIB config overrides
      template:
        src: "{{ kolla_ansible_full_src_dir }}/tests/templates/bifrost-dib-overrides.j2"
        dest: /etc/kolla/config/bifrost/dib.yml
      when: scenario == "bifrost"
      delegate_to: "primary"

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

    - name: create deamon.json for nodepool cache
      vars:
        infra_dockerhub_mirror: "http://{{ zuul_site_mirror_fqdn }}:8081/registry-1.docker/"
      template:
        src: "{{ kolla_ansible_full_src_dir }}/tests/templates/docker_daemon.json.j2"
        dest: "/etc/docker/daemon.json"
      become: true

    - name: install kolla-ansible requirements
      pip:
Jeffrey Zhang's avatar
Jeffrey Zhang committed
        requirements: "{{ ansible_env.HOME }}/{{ kolla_ansible_src_dir }}/requirements.txt"
      become: true

    - name: copy passwords.yml file
      copy:
        src: "{{ kolla_ansible_full_src_dir }}/etc/kolla/passwords.yml"
        dest: /etc/kolla/passwords.yml

    - name: generate passwords
Jeffrey Zhang's avatar
Jeffrey Zhang committed
      shell: "{{ kolla_ansible_src_dir }}/tools/generate_passwords.py"

    - name: slurp kolla passwords
      slurp:
        src: /etc/kolla/passwords.yml
      register: passwords_yml

    - name: write out kolla SSH private key
      copy:
        content: "{{ (passwords_yml.content | b64decode | from_yaml).kolla_ssh_key.private_key }}"
        dest: ~/.ssh/id_rsa_kolla
        mode: 0600

    - name: authorise kolla public key for zuul user
      authorized_key:
        user: "{{ ansible_env.USER }}"
        key: "{{ (passwords_yml.content | b64decode | from_yaml).kolla_ssh_key.public_key }}"
      # Delegate to each host in turn. If more tasks require execution on all
      # hosts in future, break out into a separate play.
      with_inventory_hostnames:
        - all
      delegate_to: "{{ item }}"
    - name: generate ceph config overrides
      template:
        src: "{{ kolla_ansible_full_src_dir }}/tests/templates/ceph-overrides.j2"
        dest: /etc/kolla/config/ceph.conf
      when: scenario == "ceph"
      delegate_to: "primary"

    - name: Run setup_gate.sh script
      shell:
        cmd: tools/setup_gate.sh
        executable: /bin/bash
        chdir: "{{ kolla_ansible_src_dir }}"
      environment:
        BASE_DISTRO: "{{ base_distro }}"
        INSTALL_TYPE: "{{ install_type }}"
        NODEPOOL_TARBALLS_MIRROR: "http://{{ zuul_site_mirror_fqdn }}:8080/tarballs"
        BUILD_IMAGE: "{{ need_build_image }}"
        KOLLA_SRC_DIR: "{{ ansible_env.HOME }}/src/git.openstack.org/openstack/kolla"
        ACTION: "{{ scenario }}"

    - block:
        - name: Run deploy.sh script
          shell:
            cmd: tests/deploy.sh
            executable: /bin/bash
            chdir: "{{ kolla_ansible_src_dir }}"
          environment:
            ACTION: "{{ scenario }}"

        - name: Run test-openstack.sh script
          shell:
            cmd: tests/test-openstack.sh
            executable: /bin/bash
            chdir: "{{ kolla_ansible_src_dir }}"
          environment:
            ACTION: "{{ scenario }}"

        - name: Run reconfigure.sh script
          shell:
            cmd: tests/reconfigure.sh
            executable: /bin/bash
            chdir: "{{ kolla_ansible_src_dir }}"
          environment:
            ACTION: "{{ scenario }}"

        - name: Run upgrade.sh script
          shell:
            cmd: tests/upgrade.sh
            executable: /bin/bash
            chdir: "{{ kolla_ansible_src_dir }}"
          environment:
            ACTION: "{{ scenario }}"
      when: scenario != "bifrost"

    - block:
        - name: Run deploy-bifrost.sh script
          shell:
            cmd: tests/deploy-bifrost.sh
            executable: /bin/bash
            chdir: "{{ kolla_ansible_src_dir }}"

        - name: Run test-bifrost.sh script
          shell:
            cmd: tests/test-bifrost.sh
            executable: /bin/bash
            chdir: "{{ kolla_ansible_src_dir }}"

        - name: Run upgrade-bifrost.sh script
          shell:
            cmd: tests/upgrade-bifrost.sh
            executable: /bin/bash
            chdir: "{{ kolla_ansible_src_dir }}"
      when: scenario == "bifrost"

    - name: Run check-failure.sh script
      shell:
        cmd: tests/check-failure.sh
        executable: /bin/bash
Jeffrey Zhang's avatar
Jeffrey Zhang committed
        chdir: "{{ kolla_ansible_src_dir }}"