diff --git a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/Dockerfile b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/Dockerfile new file mode 100644 index 000000000..e0534b4d1 --- /dev/null +++ b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/Dockerfile @@ -0,0 +1,37 @@ +# Molecule managed +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi + +{% for pkg in item.easy_install | default([]) %} +# install pip for centos where there is no python-pip rpm in default repos +RUN easy_install {{ pkg }} +{% endfor %} + + +CMD ["sh", "-c", "while true; do sleep 10000; done"] diff --git a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/converge.yml b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/converge.yml new file mode 100644 index 000000000..04483821e --- /dev/null +++ b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/converge.yml @@ -0,0 +1,39 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + become: true + vars: + tripleo_kernel_args: "test=1" + tasks: + - name: create kernelargs entry with the older name + lineinfile: + dest: /etc/default/grub + regexp: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*' + insertafter: '^GRUB_CMDLINE_LINUX.*' + line: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ tripleo_kernel_args }} "' + - name: create append entry with older name + lineinfile: + dest: /etc/default/grub + line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX:+$GRUB_CMDLINE_LINUX }${TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"' + insertafter: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*' + - include_role: + name: "tripleo_kernel" + tasks_from: kernelargs.yml + vars: + tripleo_kernel_defer_reboot: true diff --git a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/molecule.yml b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/molecule.yml new file mode 100644 index 000000000..29fb5e7e9 --- /dev/null +++ b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/molecule.yml @@ -0,0 +1,49 @@ +--- +driver: + name: delegated + options: + managed: false + login_cmd_template: >- + ssh + -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=no + -o Compression=no + -o TCPKeepAlive=yes + -o VerifyHostKeyDNS=no + -o ForwardX11=no + -o ForwardAgent=no + {instance} + ansible_connection_options: + ansible_connection: ssh + +log: true + +platforms: + - name: instance + +provisioner: + name: ansible + config_options: + defaults: + fact_caching: jsonfile + fact_caching_connection: /tmp/molecule/facts + inventory: + hosts: + all: + hosts: + instance: + ansible_host: localhost + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles" + +scenario: + test_sequence: + - prepare + - converge + - check + - verify + +verifier: + name: ansible diff --git a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/prepare.yml b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/prepare.yml @@ -0,0 +1,21 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + roles: + - role: test_deps diff --git a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/verify.yml b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/verify.yml new file mode 100644 index 000000000..7240042df --- /dev/null +++ b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs-update/verify.yml @@ -0,0 +1,46 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Verify + hosts: all + become: true + gather_facts: false + tasks: + - name: Check if the kernel args is applied to the grub file + lineinfile: + path: /etc/default/grub + line: 'GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" test=1 "' + state: present + check_mode: true + register: grub + failed_when: (grub is changed) or (grub is failed) + - name: Check if the older name entries are removed + lineinfile: + path: /etc/default/grub + regexp: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*' + state: absent + check_mode: true + register: grub + failed_when: (grub is changed) or (grub is failed) + - name: Check if the older name entries are removed for append + lineinfile: + path: /etc/default/grub + regexp: '.*{TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}.*' + state: absent + check_mode: true + register: grub + failed_when: (grub is changed) or (grub is failed) diff --git a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/molecule.yml b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/molecule.yml index 9b1e4328d..29fb5e7e9 100644 --- a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/molecule.yml +++ b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/molecule.yml @@ -42,6 +42,7 @@ scenario: test_sequence: - prepare - converge + - check - verify verifier: diff --git a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/verify.yml b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/verify.yml index 04095fa0e..31f44b527 100644 --- a/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/verify.yml +++ b/tripleo_ansible/roles/tripleo_kernel/molecule/kernelargs/verify.yml @@ -23,7 +23,7 @@ - name: Check if the kernel args is applied to the grub file lineinfile: name: /etc/default/grub - line: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" test=1 "' + line: 'GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" test=1 "' state: present check_mode: true register: grub diff --git a/tripleo_ansible/roles/tripleo_kernel/tasks/kernelargs.yml b/tripleo_ansible/roles/tripleo_kernel/tasks/kernelargs.yml index 3075e67fa..d709dd1e1 100644 --- a/tripleo_ansible/roles/tripleo_kernel/tasks/kernelargs.yml +++ b/tripleo_ansible/roles/tripleo_kernel/tasks/kernelargs.yml @@ -20,17 +20,26 @@ # Kernel Args Configuration - block: - - name: Ensure the kernel args ( {{ tripleo_kernel_args }} ) is present as TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS + # Leapp does not recognise grun entries starting other than GRUB + # It results wrong formatting of entries in file /etc/default/grub + # In order to fix it for FFU (queens to train), TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS has been renamed + # Ensure the fresh deployment is also alinged with the same name + - name: Delete older name TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS entries if present lineinfile: dest: /etc/default/grub - regexp: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*' + regexp: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS' + state: absent + - name: Ensure the kernel args ( {{ tripleo_kernel_args }} ) is present as GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS + lineinfile: + dest: /etc/default/grub + regexp: '^GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*' insertafter: '^GRUB_CMDLINE_LINUX.*' - line: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ tripleo_kernel_args }} "' - - name: Add TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS to the GRUB_CMDLINE_LINUX parameter + line: 'GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ tripleo_kernel_args }} "' + - name: Add GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS to the GRUB_CMDLINE_LINUX parameter lineinfile: dest: /etc/default/grub - line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX:+$GRUB_CMDLINE_LINUX }${TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"' - insertafter: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*' + line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX:+$GRUB_CMDLINE_LINUX }${GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"' + insertafter: '^GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*' - name: Check grub config paths stat: path: "{{ item }}"