Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into task-add-git-ssh-…
Browse files Browse the repository at this point in the history
…deploykeys
  • Loading branch information
jzandbergen committed Apr 13, 2021
2 parents 95195af + 8b32287 commit ec5fd0f
Show file tree
Hide file tree
Showing 16 changed files with 233 additions and 159 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Tests

on: [push, pull_request]

jobs:
Tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
os:
- centos
- debian
- ubuntu
steps:
- uses: actions/checkout@v2

- name: Set Python Cache Key
run: echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV

- uses: actions/cache@v2
with:
path: |
bundle
virtualenv
key: Tests-${{ matrix.os }}-${{ env.PY }}-${{ hashFiles('Gemfile', 'test-requirements.txt') }}

- name: Install System Deps
run: |
sudo apt-get update
sudo apt-get install -y curl git python3-pip ruby-dev ruby-bundler shellcheck virtualenv
- name: Install Python Deps
run: |
if [ ! -e virtualenv/bin/activate ]; then /usr/bin/virtualenv -p /usr/bin/python3 virtualenv; fi
. virtualenv/bin/activate
pip3 install -U -r test-requirements.txt
- name: Install Ruby Deps
run: |
/usr/bin/bundle config set --local path 'bundle'
/usr/bin/bundle config set --local without 'vagrant windows'
/usr/bin/bundle install
- name: Install GPG Key
run: |
install -d -m 700 gpgkeys
gpg --no-default-keyring --homedir gpgkeys --import < tests/gpgkeys/test.txt
- name: Test
run: |
. virtualenv/bin/activate
shellcheck lib/kitchen/provisioner/*.sh*
shellcheck assets/*.sh*
LANG=en_US.UTF-8 /usr/bin/bundle exec rake "integration:verify[${{ matrix.os }}]"
/usr/bin/bundle exec kitchen list ${{ matrix.os }}
- name: Cleanup
run: |
/usr/bin/bundle exec rake "integration:destroy[${{ matrix.os }}]"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ html/
.idea_modules/
atlassian-ide-plugin.xml
.vscode

# rbenv
.ruby-version
59 changes: 22 additions & 37 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ driver:
use_sudo: false
socket: <%= ENV['DOCKER_HOST'] || 'unix:///var/run/docker.sock' %>
provision_command:
- DEBIAN_FRONTEND=noninteractive apt-get install -y python-pip python-dev gcc git locales console-data gnupg
- DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip python3-dev gcc git locales console-data gnupg
- mkdir -p /run/sshd
- echo en_US.UTF-8 UTF-8 >> /etc/locale.gen; locale-gen; update-locale 'LANG="en_US.UTF-8"'
- echo export LANG=en_US.UTF-8 > ~kitchen/.bashrc
- echo 'export PATH=$PATH:/usr/sbin:/sbin' >> ~kitchen/.bashrc
provisioner:
name: salt_solo
salt_install: bootstrap
salt_version: latest
salt_bootstrap_url: https://bootstrap.saltstack.com
salt_bootstrap_options: -X -p git -p curl -p sudo
salt_version: 3000.6
salt_bootstrap_url: https://bootstrap.saltproject.io
salt_bootstrap_options: -X -x python3 -p git -p curl -p sudo stable 3000.6
pip_bin: pip3
formula: tests
require_chef: false
gpg_key: [email protected]
Expand Down Expand Up @@ -75,45 +79,28 @@ platforms:
driver:
run_command: '/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no -o PasswordAuthentication=yes -o PidFile=/tmp/sshd.pid'
provisioner:
salt_apt_repo: 'https://repo.saltstack.com/apt/ubuntu/18.04/amd64'
salt_apt_repo_key: 'https://repo.saltstack.com/apt/ubuntu/18.04/amd64/latest/SALTSTACK-GPG-KEY.pub'
salt_apt_repo: 'https://repo.saltproject.io/py3/ubuntu/18.04/amd64/archive'
salt_apt_repo_key: 'https://repo.saltproject.io/py3/ubuntu/18.04/amd64/latest/SALTSTACK-GPG-KEY.pub'
init_environment: |
sudo mkdir -p /tmp/kitchen/var/cache/salt/master
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y software-properties-common
salt_bootstrap_options: -X -p git -p curl -p sudo -p software-properties-common
- name: ubuntu-16.04
salt_bootstrap_options: -X -x python3 -p git -p curl -p sudo -p software-properties-common stable 3000.6
- name: debian-10
provisioner:
init_environment: |
sudo mkdir -p /tmp/kitchen/var/cache/salt/master
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y software-properties-common
salt_bootstrap_options: -X -p git -p curl -p sudo -p software-properties-common
- name: debian-8
provisioner:
salt_apt_repo: 'https://repo.saltstack.com/apt/debian/8/amd64'
salt_apt_repo_key: 'https://repo.saltstack.com/apt/debian/8/amd64/latest/SALTSTACK-GPG-KEY.pub'
- name: debian-9
provisioner:
salt_apt_repo: 'https://repo.saltstack.com/apt/debian/9/amd64'
salt_apt_repo_key: 'https://repo.saltstack.com/apt/debian/9/amd64/latest/SALTSTACK-GPG-KEY.pub'
- name: centos-7
salt_apt_repo: 'https://repo.saltproject.io/py3/debian/10/amd64/archive'
salt_apt_repo_key: 'https://repo.saltproject.io/py3/debian/10/amd64/latest/SALTSTACK-GPG-KEY.pub'
- name: centos-8
driver_config:
provision_command:
- echo . /etc/profile >> ~kitchen/.bashrc
- echo export LANG=en_US.UTF-8 >> ~kitchen/.bashrc
- sed -i '/secure_path/d' /etc/sudoers
- yum install -y epel-release
- yum install -y python-pip python-devel gcc git gcc-c++
provisioner:
salt_yum_repo: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/%s'
salt_yum_rpm_key: 'https://repo.saltstack.com/yum/redhat/7/x86_64/latest/SALTSTACK-GPG-KEY.pub'
- name: centos-6
- yum install -y python3-pip python3-devel gcc git gcc-c++
provisioner:
salt_yum_repo: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/%s'
salt_yum_rpm_key: 'https://repo.saltstack.com/yum/redhat/6/x86_64/latest/SALTSTACK-GPG-KEY.pub'
pip_bin: pip2.7
driver_config:
provision_command:
- yum install -y epel-release https://centos6.iuscommunity.org/ius-release.rpm
- yum install -y python27-pip python27-devel gcc git gcc-c++
salt_yum_repo: 'https://repo.saltproject.io/py3/redhat/8/x86_64/archive/%s'
salt_yum_rpm_key: 'https://repo.saltproject.io/py3/redhat/8/x86_64/latest/SALTSTACK-GPG-KEY.pub'
<% if @vagrant != false %>
- name: windows-2012r2
driver:
Expand All @@ -133,7 +120,7 @@ platforms:
$OldPath = (Get-ItemProperty -Path "$Reg" -Name PATH).Path
$NewPath= $OldPath + ’;’ + $AddedLocation
Set-ItemProperty -Path "$Reg" -Name PATH –Value $NewPath
salt_bootstrap_url: https://raw.githubusercontent.com/saltstack/salt-bootstrap/develop/bootstrap-salt.ps1
salt_bootstrap_url: https://winbootstrap.saltproject.io/develop
salt_bootstrap_options: ''
state_top:
base:
Expand Down Expand Up @@ -170,7 +157,6 @@ suites:
provisioner:
salt_install: apt
includes:
- debian-8
- debian-9
- ubuntu-18.04
- ubuntu-16.04
Expand All @@ -181,7 +167,6 @@ suites:
sudo mkdir -p /tmp/kitchen/var/cache/salt/master
sudo yum install -y git
includes:
- centos-6
- centos-7
- name: bootstrap
<% if @vagrant != false %>
Expand Down
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
# kitchen-salt #

[![Gem Version](https://badge.fury.io/rb/kitchen-salt.svg)](https://badge.fury.io/rb/kitchen-salt)
[![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/kitchen-salt?type=total&color=brightgreen)](https://rubygems.org/gems/kitchen-salt)
[![Build Status](https://travis-ci.com/saltstack/kitchen-salt.png)](https://travis-ci.com/saltstack/kitchen-salt)
[![Build Status](https://github.com/saltstack/kitchen-salt/workflows/Tests/badge.svg)](https://github.com/saltstack/kitchen-salt/actions)

A Test Kitchen Provisioner for Salt

The provider works by generating a salt-minion config, creating pillars based on attributes in .kitchen.yml and calling salt-call.

This provisioner is tested with kitchen-docker against CentOS, Ubuntu, and Debian.

## Documentation ##
## Generate and locally view kitchen-salt docs ##

To view the docs that were originally generated by this repository and hosted by Salt Project, the following should generate a local copy of the documentation.

# Clear any locally generated documentation
rm -rf html/

# Generate HTML documentation of kitchen-salt
bundle install
bundle exec yard doc
firefox html/index.html

# OPTIONAL
# Start a local http server to view the rendered docs
# Accessible via http://localhost:8808/
bundle exec yard server docroot=html/

## Installation and Setup ##

You'll need the test-kitchen and kitchen-salt gem's installed in your system, along with kitchen-vagrant or some other suitable driver for test-kitchen. Please see the [gettingstarted documentation](docs/gettingstarted.md).

## Provisioner Options ##

More details on all the configuration options are in the [provisioner_options documentation](docs/provisioner_options.md).

## Requirements ##

You'll need a driver box that is supported by the SaltStack [bootstrap](https://github.com/saltstack/salt-bootstrap) system.

## Continuous Integration and Testing ##

PR's and other changes should validated using Github Actions, kitchen-docker, multiple state dependencies, the modified version of kitchen-salt and the latest version of test-kitchen.

## Releasing ##

<https://kitchen.saltstack.com>
# hack. work. test.
git add stuff
git commit -v
gem bump --release --tag
4 changes: 2 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# kitchen-salt #
[![Gem Version](https://badge.fury.io/rb/kitchen-salt.svg)](https://badge.fury.io/rb/kitchen-salt)
[![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/kitchen-salt?type=total&color=brightgreen)](https://rubygems.org/gems/kitchen-salt)
[![Build Status](https://travis-ci.org/saltstack/kitchen-salt.png)](https://travis-ci.org/saltstack/kitchen-salt)
[![Build Status](https://github.com/saltstack/kitchen-salt/workflows/Tests/badge.svg)](https://github.com/saltstack/kitchen-salt/actions)

A Test Kitchen Provisioner for Salt

Expand All @@ -24,7 +24,7 @@ More details on all the configuration options are in {file:docs/provisioner_opti
You'll need a driver box that is supported by the SaltStack [bootstrap](https://github.com/saltstack/salt-bootstrap) system.

## Continuous Integration and Testing
PR's and other changes should validated using Travis-CI, kitchen-docker, multiple state dependencies, the modified version of kitchen-salt and the latest version of test-kitchen.
PR's and other changes should validated using Github Actions, kitchen-docker, multiple state dependencies, the modified version of kitchen-salt and the latest version of test-kitchen.

## Releasing ##

Expand Down
3 changes: 2 additions & 1 deletion assets/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ install_deps() {
exit 1
fi

command -v ruby
# make links to binaries
mkdir -p /opt/chef/embedded/bin/
[ ! -e /opt/chef/embedded/bin/gem ] && ln -s "$(command -v gem)" /opt/chef/embedded/bin/
Expand All @@ -92,7 +93,7 @@ elif test -f "/etc/arch-release"; then
platform="arch"
elif test -f "/etc/system-release"; then
platform="$(sed 's/^\(.\+\) release.\+/\1/' /etc/system-release | tr '[:upper:]' '[:lower:]')"
if test "$platform" = "amazon linux ami"; then
if test "$platform" = "amazon linux ami" || test "$platform" = "amazon linux"; then
platform="redhat"
fi
elif test -f "etc/alpine-release"; then
Expand Down
27 changes: 8 additions & 19 deletions docs/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,19 @@ For Linux, there is an [installer script](https://github.com/rbenv/rbenv-install

The following instructions will allow for a global install of rbenv.

1. Install the dependencies for building ruby
- centos

sudo yum install -y openssl-devel readline-devel zlib-devel bzip2 gcc make git

- ubuntu

sudo apt update
sudo apt install -y libssl-dev libreadline-dev zlib1g-dev bzip2 gcc make git
1. Install the dependencies for building ruby, referencing the `ruby-build` [Suggested build environment](https://github.com/rbenv/ruby-build/wiki#suggested-build-environment) documentation.

1. clone git repos and setup path

sudo git clone git://github.com/rbenv/rbenv.git /usr/local/rbenv
sudo mkdir /usr/local/rbenv/plugins
sudo git clone git://github.com/rbenv/ruby-build.git /usr/local/rbenv/plugins/ruby-build
sudo tee /etc/profile.d/rbenv.sh <<< 'export PATH="/usr/local/rbenv/plugins/ruby-build/bin:/usr/local/rbenv/bin:$PATH"'
sudo tee -a /etc/profile.d/rbenv.sh <<< 'source <(rbenv init -)'

now the shell needs to be restarted so that the rbenv commands are in the path, and then `rbenv init -` adds the shims path to the PATH as well.
- [Basic GitHub Checkout/setup of rbenv](https://github.com/rbenv/rbenv#basic-github-checkout)
- [Installation of `ruby-build`](https://github.com/rbenv/ruby-build#installation)

1. Install ruby and set it as the version to use by default
1. Install ruby and set `2.6.3` as the version to use by default. Salt uses this version of Ruby in CI pipelines, which is why it is preferred here, but newer versions of ruby may work without issue.

rbenv install 2.4.2
rbenv global 2.4.2
rbenv install 2.6.3
rbenv local 2.6.3
# OPTIONAL: Set global default version
# rbenv global 2.6.3

If gemsets are needed, the [rbenv-gemset](https://github.com/jf/rbenv-gemset) plugin can be added to the gemsets repository.

Expand Down
8 changes: 4 additions & 4 deletions docs/jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Setting up kitchen to run tests like Jenkins #

The new SaltStack Jenkins setup at https://jenkinsci.saltstack.com is using kitchen and the kitchen-ec2 driver to build servers for testing.
The new SaltStack Jenkins setup at https://jenkins.saltproject.io is using kitchen and the kitchen-ec2 driver to build servers for testing.

The only thing that needs to be available is `ruby` and `gem` or `bundler` (`gem install bundler`). The rest of this guide will be using bundler. If you need to install ruby, there is a guide available for managed versions using rbenv or rvm available in the {file:docs/gettingstarted.md} doc.

Expand Down Expand Up @@ -113,7 +113,7 @@ The following fields will need to be filled out:
username: ec2-user
provisioner:
salt_bootstrap_options: -UX -p rsync git v<%= version %>
salt_bootstrap_url: https://raw.githubusercontent.com/saltstack/salt-bootstrap/develop/bootstrap-salt.sh
salt_bootstrap_url: https://bootstrap.saltproject.io
- name: centos-7
driver:
tags:
Expand Down Expand Up @@ -177,7 +177,7 @@ The following fields will need to be filled out:
Name: kitchen-windows-2016-<%= 10.times.map{[('a'..'z').to_a, (0..9).to_a].join[rand(36)]}.join %>
retryable_tries: 120
provisioner:
salt_bootstrap_url: https://raw.githubusercontent.com/saltstack/salt-bootstrap/develop/bootstrap-salt.ps1
salt_bootstrap_url: https://winbootstrap.saltproject.io
salt_bootstrap_options: -version <%= version %> -runservice false
init_environment: |
reg add "hklm\system\currentcontrolset\control\session manager\memory management" /v pagingfiles /t reg_multi_sz /d "d:\pagefile.sys 4096 8192" /f
Expand Down Expand Up @@ -329,7 +329,7 @@ And when the machine is no longer useful, it can be deleted.

bundle exec kitchen destroy py2-centos-7

And that is the life cycle of the testing instances in https://jenkinsci.saltstack.com
And that is the life cycle of the testing instances in https://jenkins.saltproject.io

In jenkins we go through each of the kitchen steps above, but you can use `test`, which will create, then converge, then verify, and if verify passes, the instance will be deleted.

Expand Down
Loading

0 comments on commit ec5fd0f

Please sign in to comment.