809cada20a
There is a lot of logic in the check.sh script of the openstack functional tests. Extract into a single location in /tools and call it from the install and container tests. Change-Id: Ib5728f5cee917c73d0da276d36da5776dee279fc
146 lines
6.0 KiB
YAML
146 lines
6.0 KiB
YAML
- hosts: all
|
|
vars:
|
|
nodepool_config_dir: "/etc/nodepool"
|
|
nodepool_log_dir: "/var/log/nodepool"
|
|
NODEPOOL_KEY: "$HOME/.ssh/id_nodepool"
|
|
NODEPOOL_KEY_NAME: "root"
|
|
NODEPOOL_PUBKEY: "$HOME/.ssh/id_nodepool.pub"
|
|
NODEPOOL_INSTALL: "$HOME/nodepool-venv"
|
|
NODEPOOL_CACHE_GET_PIP: "/opt/stack/cache/files/get-pip.py"
|
|
NODEPOOL_CONFIG: "{{ nodepool_config_dir }}/nodepool.yaml"
|
|
NODEPOOL_DIB_BASE_PATH: "/opt/dib"
|
|
launcher_logging_config: "{{ nodepool_config_dir }}/launcher-logging.conf"
|
|
launcher_logging_arg: "{{ '-l '+ launcher_logging_config if nodepool_debug is defined and nodepool_debug else '' }}"
|
|
builder_logging_config: "{{ nodepool_config_dir }}/builder-logging.conf"
|
|
builder_logging_arg: "{{ '-l '+ builder_logging_config if nodepool_debug is defined and nodepool_debug else '' }}"
|
|
tasks:
|
|
- name: Write clouds.yaml
|
|
include_tasks: write_clouds_yaml.yaml
|
|
- name: Install software for DIB
|
|
become: true
|
|
package:
|
|
name:
|
|
- qemu-utils
|
|
- kpartx
|
|
- name: Install extra software for DIB
|
|
when: nodepool_extra_packages is defined
|
|
become: true
|
|
package:
|
|
name: "{{ nodepool_extra_packages }}"
|
|
- name: Create cache directory
|
|
file:
|
|
path: .cache/openstack
|
|
state: directory
|
|
- name: Create nodepool flavors
|
|
args:
|
|
executable: /bin/bash
|
|
shell: |
|
|
source /opt/devstack/openrc admin admin
|
|
nova flavor-create nodepool-512 64 512 5 1
|
|
nova flavor-create nodepool-1024 128 1024 5 1
|
|
- name: Create security groups
|
|
args:
|
|
executable: /bin/bash
|
|
shell: |
|
|
source /opt/devstack/openrc admin admin
|
|
openstack --os-project-name demo --os-username demo security group rule create --ingress --protocol tcp --dst-port 1:65535 --remote-ip 0.0.0.0/0 default
|
|
openstack --os-project-name demo --os-username demo security group rule create --ingress --protocol udp --dst-port 1:65535 --remote-ip 0.0.0.0/0 default
|
|
- name: Create unmanaged VM
|
|
args:
|
|
executable: /bin/bash
|
|
shell: |
|
|
source /opt/devstack/openrc admin admin
|
|
openstack network list
|
|
cirros_image=$(openstack --os-project-name demo --os-username demo image list | grep cirros | awk '{print $4}' | head -n1)
|
|
openstack --os-project-name demo --os-username demo server create --flavor cirros256 --image $cirros_image unmanaged-vm --network public
|
|
|
|
- name: Create nodepool SSH keypair
|
|
args:
|
|
executable: /bin/bash
|
|
shell: |
|
|
source /opt/devstack/openrc admin admin
|
|
ssh-keygen -f {{ NODEPOOL_KEY }} -P ""
|
|
nova --os-project-name demo --os-username demo keypair-add --pub-key {{ NODEPOOL_PUBKEY }} {{ NODEPOOL_KEY_NAME }}
|
|
|
|
- name: Write nodepool elements
|
|
args:
|
|
executable: /bin/bash
|
|
shell:
|
|
cmd: |
|
|
sudo mkdir -p $(dirname {{ NODEPOOL_CONFIG }})/elements/nodepool-setup/install.d
|
|
sudo mkdir -p $(dirname {{ NODEPOOL_CONFIG }})/elements/nodepool-setup/root.d
|
|
cat > /tmp/40-nodepool-setup <<EOF
|
|
sudo mkdir -p /etc/nodepool
|
|
# Make it world writeable so nodepool can write here later.
|
|
sudo chmod 777 /etc/nodepool
|
|
EOF
|
|
cat > /tmp/50-apt-allow-unauthenticated <<EOF
|
|
if [ -d "\$TARGET_ROOT/etc/apt/apt.conf.d" ]; then
|
|
echo "APT::Get::AllowUnauthenticated \"true\";" | sudo tee \$TARGET_ROOT/etc/apt/apt.conf.d/95allow-unauthenticated
|
|
echo "Acquire::AllowInsecureRepositories \"true\";" | sudo tee -a \$TARGET_ROOT/etc/apt/apt.conf.d/95allow-unauthenticated
|
|
fi
|
|
EOF
|
|
sudo mv /tmp/40-nodepool-setup \
|
|
$(dirname {{ NODEPOOL_CONFIG }})/elements/nodepool-setup/install.d/40-nodepool-setup
|
|
sudo chmod a+x \
|
|
$(dirname {{ NODEPOOL_CONFIG }})/elements/nodepool-setup/install.d/40-nodepool-setup
|
|
sudo mv /tmp/50-apt-allow-unauthenticated \
|
|
$(dirname {{ NODEPOOL_CONFIG }})/elements/nodepool-setup/root.d/50-apt-allow-unauthenticated
|
|
sudo chmod a+x \
|
|
$(dirname {{ NODEPOOL_CONFIG }})/elements/nodepool-setup/root.d/50-apt-allow-unauthenticated
|
|
sudo mkdir -p {{ NODEPOOL_DIB_BASE_PATH }}/images
|
|
sudo mkdir -p {{ NODEPOOL_DIB_BASE_PATH }}/tmp
|
|
sudo mkdir -p {{ NODEPOOL_DIB_BASE_PATH }}/cache
|
|
sudo chown -R {{ ansible_user }}:{{ ansible_user }} {{ NODEPOOL_DIB_BASE_PATH }}
|
|
|
|
- name: Write nodepool config
|
|
become: true
|
|
template:
|
|
src: nodepool.yaml.j2
|
|
dest: "{{ NODEPOOL_CONFIG }}"
|
|
|
|
- name: Validate nodepool config
|
|
command: "./.venv/bin/nodepool -c {{ NODEPOOL_CONFIG }} config-validate"
|
|
|
|
- name: Create nodepool runtime dirs
|
|
become: true
|
|
file:
|
|
path: '{{ item }}'
|
|
state: directory
|
|
owner: '{{ ansible_user }}'
|
|
group: '{{ ansible_user }}'
|
|
loop:
|
|
- /var/run/nodepool
|
|
- '{{ nodepool_log_dir }}'
|
|
|
|
- name: Write builder logging config
|
|
become: true
|
|
template:
|
|
src: logging.conf.j2
|
|
dest: "{{ builder_logging_config }}"
|
|
vars:
|
|
log_file: "{{ nodepool_log_dir }}/nodepool-builder.log"
|
|
|
|
- name: Write launcher logging config
|
|
become: true
|
|
template:
|
|
src: logging.conf.j2
|
|
dest: "{{ launcher_logging_config }}"
|
|
vars:
|
|
log_file: "{{ nodepool_log_dir }}/nodepool-launcher.log"
|
|
|
|
# FIXME: don't use activate once this merges:
|
|
# https://review.opendev.org/666177 Use the DIB installed in the virtualenv if running there
|
|
- name: Start nodepool builder
|
|
shell: |
|
|
. ./.venv/bin/activate
|
|
nodepool-builder {{ builder_logging_arg}} -c {{ NODEPOOL_CONFIG }}
|
|
|
|
- name: Start nodepool launcher
|
|
command: "./.venv/bin/nodepool-launcher {{ launcher_logging_arg }} -c {{ NODEPOOL_CONFIG }}"
|
|
|
|
- name: Check nodepool functionality
|
|
command: "{{ zuul.projects['opendev.org/zuul/nodepool'].src_dir }}/tools/functional-test-check.sh"
|
|
environment:
|
|
NODEPOOL_FUNCTIONAL_CHECK: 'installed'
|