Skip to content

Commit

Permalink
feat(kitchen): use provision_command for amazonlinux-1 images
Browse files Browse the repository at this point in the history
* Performance improvement as outlined in this comment:
  - saltstack-formulas/vault-formula#50 (review)
* Tests appear to confirm this:
  - https://travis-ci.org/myii/vault-formula/builds/607049255 (slower)
  - https://travis-ci.org/myii/vault-formula/builds/607873289 (faster)
  • Loading branch information
myii committed Nov 6, 2019
1 parent df1b8d6 commit b7835f2
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions ssf/files/default/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,37 @@
{%- endfilter %}
{%- endmacro %}

{%- macro format_driver_image(os, os_ver, salt_ver, py_ver) %}
{%- macro format_driver_image(os, os_ver, salt_ver, py_ver, pre_salted) %}
{%- filter indent(6) %}
{#- Temporary use of `develop` instead of `master` until it is available #}
{%- if [os, os_ver, salt_ver] == ['amazonlinux', 2, 'master'] %}
{%- set salt_ver = 'develop' %}
{%- endif %}
{#- Use bootstrapped images for `amazonlinux-1` #}
{%- if [os, os_ver] == ['amazonlinux', 1] %}
{#- Use bootstrapped images where not already pre-salted #}
{%- if not pre_salted %}
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) %}
{%- macro format_driver_prov_cmds(os, os_ver, salt_ver, py_ver, pre_salted) %}
{#- 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 `master` #}
{%- if salt_ver == 'master' %}
{#- Specific to `master` or bootstrapped images #}
{%- if salt_ver == 'master' or not pre_salted %}
{#- Temporary use of `develop` instead of `master` until it is available #}
{%- if [os, os_ver, salt_ver] == ['amazonlinux', 2, 'master'] %}
{%- set salt_ver = 'develop' %}
{%- endif %}
{#- Append the `prov_cmds` for pre-salted images (i.e. non-bootstrap) #}
{%- if [os, os_ver] != ['amazonlinux', 1] %}
{%- 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 %}
{#- Use the appropriate bootstrap options for pre-salted images vs. bootstrapped images #}
{%- set bootstrap_options = 'XdPbfrq' if pre_salted else 'XdPfq' %}
{%- do prov_cmds.append('- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com') %}
{%- do prov_cmds.append('- sh bootstrap-salt.sh -{0} -x python{1} git {2}'.format(bootstrap_options, py_ver, salt_ver)) %}
{#- Add formula-specific provision commands #}
{%- if semrel_formula == 'deepsea' %}
{%- if os in ['centos', 'fedora'] %}
{%- do prov_cmds.append('- yum install make -y') %}
Expand Down Expand Up @@ -135,6 +135,7 @@ platforms:
{%- set os_ver = platform[1] %}
{%- set salt_ver = platform[2] %}
{%- set py_ver = platform[3] %}
{%- set pre_salted = [os, os_ver] not in [['amazonlinux', 1]] %}
{#- Display comment for each section (based on Salt version) #}
{%- set linebreak = '\n' %}
{%- set comment = '`{0}`'.format(salt_ver) %}
Expand All @@ -161,14 +162,10 @@ platforms:
{%- endif %}
- name: {{ os | replace('/', '-') }}-{{ os_ver | replace('.', '') }}-{{ salt_ver | replace('.', '-') }}-py{{ py_ver }}
driver:
{{- format_driver_image(os, os_ver, salt_ver, py_ver) }}
{{- format_driver_prov_cmds(os, os_ver, salt_ver, py_ver) }}
{{- format_driver_image(os, os_ver, salt_ver, py_ver, pre_salted) }}
{{- format_driver_prov_cmds(os, os_ver, salt_ver, py_ver, pre_salted) }}
{{- format_driver_run_cmds(os, os_ver) }}
{%- if [os, os_ver] == ['amazonlinux', 1] %}
provisioner:
salt_bootstrap_options: -XdPfq -x python{{ py_ver }} git {{ salt_ver }}
salt_install: bootstrap
{%- elif [os, os_ver] == ['opensuse/leap', 15.1] %}
{%- if [os, os_ver] == ['opensuse/leap', 15.1] %}
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
Expand Down

0 comments on commit b7835f2

Please sign in to comment.