Skip to content
Snippets Groups Projects
  • Mark Goddard's avatar
    8399fc78
    Don't use 'become' in CI tests · 8399fc78
    Mark Goddard authored
    Kolla Ansible now claims [1] to support executing as a user other than
    root.  We should ensure that this is tested in CI.
    
    This change removes the 'become' from hosts in the inventory, and sets
    the remote user to 'kolla', as configured via the bootstrap-servers
    command. The bootstrap-servers command and other ansible commands
    executed before it still need to execute as the zuul user and not as
    kolla, since kolla does not exist yet.
    
    The autogenerated SSH private key in passwords.yml is now added to the
    zuul user's SSH config, such that it can SSH as the kolla user, which
    has authorised this key.
    
    [1]
    https://blueprints.launchpad.net/kolla-ansible/+spec/ansible-specific-task-become
    
    Change-Id: I8f3587e2908bc5b8889cd6fbc01981a6186d33e6
    8399fc78
    History
    Don't use 'become' in CI tests
    Mark Goddard authored
    Kolla Ansible now claims [1] to support executing as a user other than
    root.  We should ensure that this is tested in CI.
    
    This change removes the 'become' from hosts in the inventory, and sets
    the remote user to 'kolla', as configured via the bootstrap-servers
    command. The bootstrap-servers command and other ansible commands
    executed before it still need to execute as the zuul user and not as
    kolla, since kolla does not exist yet.
    
    The autogenerated SSH private key in passwords.yml is now added to the
    zuul user's SSH config, such that it can SSH as the kolla user, which
    has authorised this key.
    
    [1]
    https://blueprints.launchpad.net/kolla-ansible/+spec/ansible-specific-task-become
    
    Change-Id: I8f3587e2908bc5b8889cd6fbc01981a6186d33e6
run.yml 5.53 KiB
---
- 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

- hosts: primary
  vars:
    kolla_inventory_path: "/etc/kolla/inventory"
    logs_dir: "/tmp/logs"
    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 }}"
    need_build_image: false
  tasks:
    - name: ensure /etc/kolla exists
      file:
        path: "/etc/kolla"
        state: "directory"
        mode: 0777
      become: true

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

    # FIXME: in multi node env, api_interface may be different on each node.
    - name: detect api_interface_name variable
      vars:
        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'] }}"

    - name: generate global.yml file
      template:
        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: