Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kitchen): use bootstrapped opensuse images until 2019.2.2 #52

Merged
merged 2 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ssf_node_anchors:
# An alternative method could be to use:
# `git describe --abbrev=0 --tags`
# yamllint disable rule:line-length
title: 'test(inspec): add remaining platforms [skip ci]'
body: '* Automated using https://github.com/myii/ssf-formula/pull/51'
title: 'ci(kitchen): use bootstrapped `opensuse` images until `2019.2.2` [skip ci]'
body: '* Automated using https://github.com/myii/ssf-formula/pull/52'
# yamllint enable rule:line-length
github:
owner: saltstack-formulas
Expand Down
106 changes: 71 additions & 35 deletions ssf/files/default/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,71 @@
{%- endif %}
{%- endfilter %}
{%- endmacro %}

{%- macro format_driver_image(os, os_ver, salt_ver, py_ver) %}
{%- filter indent(6) %}
{%- if os == 'opensuse/leap' %}
image: {{ os }}:{{ os_ver }}
{%- else %}
image: netmanagers/salt-{{ salt_ver }}-py{{ py_ver }}:{{ os | replace('/', '-') }}-{{ os_ver }}
{%- endif %}
{%- endfilter %}
{%- endmacro %}

{%- macro format_driver_prov_cmds(os, os_ver, salt_ver, py_ver) %}
{#- TODO: Should really do this whole `if` block from `defaults.yaml` or `formulas.yaml`, just speeding things up right now #}
{#- Need to look at if this can be resolved from within the formulas themselves, though #}
{%- filter indent(6) %}
{%- set prov_cmds = [] %}
{#- Specific to unsalted `opensuse/leap` #}
{%- if os == 'opensuse/leap' %}
{%- do prov_cmds.append('- systemctl enable sshd.service') %}
{%- endif %}
{#- Specific to `develop` #}
{%- if salt_ver == 'develop' %}
{%- if os != 'opensuse/leap' %}
{%- do prov_cmds.append('- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com') %}
{%- do prov_cmds.append('- sh bootstrap-salt.sh -XdPbfrq -x python{0} git {1}'.format(py_ver, salt_ver)) %}
{%- endif %}
{%- if semrel_formula == 'deepsea' %}
{%- if os in ['centos', 'fedora'] %}
{%- do prov_cmds.append('- yum install make -y') %}
{%- endif %}
{%- elif semrel_formula == 'golang' %}
{%- if os in ['debian', 'ubuntu'] %}
{%- do prov_cmds.append('# https://github.com/saltstack/salt/issues/39314') %}
{%- do prov_cmds.append('- apt-get remove python-boto3 -y') %}
{%- elif os == 'opensuse/leap' %}
{%- do prov_cmds.append('# https://github.com/saltstack/salt/issues/39314') %}
{%- do prov_cmds.append('- zypper rm python-boto3 -y') %}
{%- endif %}
{%- endif %}
{%- endif %}
{#- General for all Salt versions #}
{%- if semrel_formula == 'deepsea' %}
{%- if os == 'opensuse/leap' %}
{%- do prov_cmds.append('- zypper -n in tar gzip') %}
{%- endif %}
{%- endif %}
{#- Prepare the commands if available#}
{%- if prov_cmds %}
provision_command:
{%- for prov_cmd in prov_cmds %}
{{ prov_cmd }}
{%- endfor %}
{%- endif %}
{%- endfilter %}
{%- endmacro %}

{%- macro format_driver_run_cmds(os, os_ver) %}
{%- filter indent(6) %}
{%- if os in ['opensuse/leap', 'arch-base'] %}
run_command: /usr/lib/systemd/systemd
{%- elif [os, os_ver] == ['centos', 6] %}
run_command: /sbin/init
{%- endif %}
{%- endfilter %}
{%- endmacro %}
# For help on this file's format, see https://kitchen.ci/
driver:
name: docker
Expand Down Expand Up @@ -100,42 +165,13 @@ platforms:
{%- else %}
- name: {{ os | replace('/', '-') }}-{{ os_ver | replace('.', '') }}-{{ salt_ver | replace('.', '-') }}-py{{ py_ver }}
driver:
image: netmanagers/salt-{{ salt_ver }}-py{{ py_ver }}:{{ os | replace('/', '-') }}-{{ os_ver }}
{%- if salt_ver == 'develop' %}
provision_command:
- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
- sh bootstrap-salt.sh -XdPbfrq -x python{{ py_ver }} git develop
{#- TODO: Should really do this whole `if` block from `defaults.yaml` or `formulas.yaml`, just speeding things up right now #}
{#- Need to look at if this can be resolved from within the formulas themselves, though #}
{%- if semrel_formula == 'deepsea' %}
{%- if os in ['centos', 'fedora'] %}
- yum install make -y
{#- Duplicated `provision_command` due to `deepsea`, try to remove eventually #}
{%- elif os == 'opensuse/leap' %}
- zypper -n in tar gzip
{%- endif %}
{%- elif semrel_formula == 'golang' %}
{%- if os in ['debian', 'ubuntu'] %}
# https://github.com/saltstack/salt/issues/39314
- apt-get remove python-boto3 -y
{%- elif os == 'opensuse/leap' %}
# https://github.com/saltstack/salt/issues/39314
- zypper rm python-boto3 -y
{%- endif %}
{%- endif %}
{%- endif %}
{#- TODO: Should really do this whole `if` block from `defaults.yaml` or `formulas.yaml`, just speeding things up right now #}
{%- if os in ['opensuse/leap', 'arch-base'] %}
{%- if os == 'opensuse/leap' and semrel_formula == 'deepsea' and salt_ver != 'develop' %}
{#- Duplicated `provision_command` due to `deepsea`, try to remove eventually #}
provision_command:
- zypper -n in tar gzip
{%- endif %}
run_command: /usr/lib/systemd/systemd
{%- elif os == 'centos' and os_ver == 6 %}
run_command: /sbin/init
{%- endif %}
{{- format_driver_image(os, os_ver, salt_ver, py_ver) }}
{{- format_driver_prov_cmds(os, os_ver, salt_ver, py_ver) }}
{{- format_driver_run_cmds(os, os_ver) }}
{%- if [os, os_ver] == ['opensuse/leap', 15] %}
provisioner:
salt_bootstrap_options: -XdPfrq -x python{{ py_ver }} git {{ salt_ver }}
salt_install: bootstrap
# Workaround to avoid intermittent failures on `opensuse-leap-15`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
Expand Down