From d691f0d1a5b3ec56756aa60a786a1d7d1b97fc9e Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Tue, 22 Jan 2019 22:35:58 -0500 Subject: [PATCH] initial commit --- .kitchen.yml | 60 +++++++++++++++++++++ .travis.yml | 16 ++++++ Gemfile | 6 +++ LICENSE | 13 +++++ README.rst | 21 ++++++++ cli53/defaults.yaml | 3 ++ cli53/init.sls | 24 +++++++++ cli53/map.jinja | 21 ++++++++ pillar.example | 5 ++ test/integration/cli53/inspec/cli53_spec.rb | 8 +++ 10 files changed, 177 insertions(+) create mode 100644 .kitchen.yml create mode 100644 .travis.yml create mode 100644 Gemfile create mode 100644 LICENSE create mode 100644 README.rst create mode 100644 cli53/defaults.yaml create mode 100644 cli53/init.sls create mode 100644 cli53/map.jinja create mode 100644 pillar.example create mode 100644 test/integration/cli53/inspec/cli53_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..5c7c430 --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,60 @@ +--- +driver: + name: docker + use_sudo: false + privileged: true + require_chef_omnibus: false + +verifier: + name: inspec + inspec_tests: + - test/integration/cli53/inspec + +platforms: + - name: ubuntu-14.04 + driver_config: + disable_upstart: false + image: ubuntu-upstart:14.04 + run_command: /sbin/init + + - name: debian-9.4 + driver_config: + run_command: /bin/systemd + + - name: ubuntu-16.04 + driver_config: + run_command: /sbin/init + + - name: centos-7 + driver_config: + run_command: /usr/lib/systemd/systemd + +provisioner: + name: salt_solo + #log_level: quiet + require_chef: false + formula: cli53 + state_top: + base: + '*': + - cli53 + pillars-from-files: + base.sls: pillar.example + pillars: + top.sls: + base: + '*': + - base + - cli53 + cli53.sls: + cli53: + register: [] + scripts: [] + +suites: + - name: cli53-client + provisioner: + pillars: + cli53.sls: + cli53: + version: 0.8.13 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f511b49 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +sudo: required +language: python +services: + - docker + +before_install: + - bundle install + +env: + matrix: + - INSTANCE: cli53-ubuntu-1404 + - INSTANCE: cli53-ubuntu-1604 + - INSTANCE: cli53-centos-7 + +script: + - bundle exec kitchen verify ${INSTANCE} diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..c94467b --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem "test-kitchen" +gem "kitchen-docker" +gem "kitchen-salt" +gem "kitchen-inspec" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d919c41 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ + Copyright (c) 2013-2015 Salt Stack Formulas + + 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. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..3024b25 --- /dev/null +++ b/README.rst @@ -0,0 +1,21 @@ +====== +cli53 +====== + +.. note:: + + See the full `Salt Formulas installation and usage instructions + `_. + +Available states +================ + +.. contents:: + :local: + +``cli53`` +------------ + +Downloads and installs the cli53 binary. + +.. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=4 sw=4 et diff --git a/cli53/defaults.yaml b/cli53/defaults.yaml new file mode 100644 index 0000000..a413ecf --- /dev/null +++ b/cli53/defaults.yaml @@ -0,0 +1,3 @@ +cli53: + version: 0.8.13 + diff --git a/cli53/init.sls b/cli53/init.sls new file mode 100644 index 0000000..ad0a82c --- /dev/null +++ b/cli53/init.sls @@ -0,0 +1,24 @@ +{%- from slspath + '/map.jinja' import cli53 with context -%} + +cli53-bin-dir: + file.directory: + - name: /usr/local/bin + - makedirs: True + +# Install cli53 +cli53-download: + file.managed: + - name: /usr/local/bin/cli53-linux-{{ cli53.arch }} + - source: https://github.com/barnybug/cli53/releases/download/{{ cli53.version }}/cli53-linux-{{ cli53.arch }} + - source_hash: https://github.com/barnybug/cli53/releases/download/{{ cli53.version }}/cli53_{{ cli53.version }}_checksums.txt + - require: + - file: cli53-bin-dir + +# Link cli53 +cli53-link: + file.symlink: + - target: cli53 + - name: /usr/local/bin/cli53-linux-{{ cli53.arch }} + - watch: + - file: cli53-download + diff --git a/cli53/map.jinja b/cli53/map.jinja new file mode 100644 index 0000000..b5a2d29 --- /dev/null +++ b/cli53/map.jinja @@ -0,0 +1,21 @@ +{% import_yaml slspath+"/defaults.yaml" as defaults %} + +{% set cli53 = salt['pillar.get']('cli53', default=defaults.cli53, merge=True) %} + +{## Add any overrides based on CPU architecture. ##} +{% set cli53 = salt['grains.filter_by']({ + 'armv6l': { + "arch": 'arm' + }, + 'armv7l': { + "arch": 'arm' + }, + 'x86_64': { + "arch": 'amd64' + } + } + ,grain="cpuarch" + ,merge=cli53) +%} + +{% do cli53.config.update({'retry_join': cli53.config.retry_join or []}) %} diff --git a/pillar.example b/pillar.example new file mode 100644 index 0000000..fc313bb --- /dev/null +++ b/pillar.example @@ -0,0 +1,5 @@ +cli53: + # Start Consul agent service and enable it at boot time + version: 0.8.13 + +# vim: ft=yaml diff --git a/test/integration/cli53/inspec/cli53_spec.rb b/test/integration/cli53/inspec/cli53_spec.rb new file mode 100644 index 0000000..8574708 --- /dev/null +++ b/test/integration/cli53/inspec/cli53_spec.rb @@ -0,0 +1,8 @@ +describe file('/usr/local/bin/cli53-linux-amd64') do + it { should exist } +end + +describe file('/usr/local/bin/cli53') do + it { should be_symlink } + its('link_path') { should eq 'cli53-linux-amd64' } +end