diff --git a/.delivery/project.toml b/.delivery/project.toml deleted file mode 100644 index 0d6f0ae9..00000000 --- a/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[local_phases] -unit = "rspec spec/" -lint = 'cookstyle --display-cop-names --extra-details' -syntax = "echo skipping" -provision = "echo skipping" -deploy = "echo skipping" -smoke = "echo skipping" -functional = "echo skipping" -cleanup = "echo skipping" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..eb3be0f5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,233 @@ +on: + pull_request: + +jobs: + markdownlint: + uses: Stromweld/github-workflows/.github/workflows/markdownlint.yml@main + + yamllint: + uses: Stromweld/github-workflows/.github/workflows/yamllint.yml@main + + jsonlint: + uses: Stromweld/github-workflows/.github/workflows/jsonlint.yml@main + + cookstylelint: + uses: Stromweld/github-workflows/.github/workflows/cookstylelint.yml@main + + integration-dokken: + runs-on: ubuntu-latest + strategy: + matrix: + os: + - centos-7 + - centos-8 + - almalinux-8 +# - almalinux-9 # TODO: uncomment this when almalinux-9 dokken image is fixed + - ubuntu-1804 + - ubuntu-2004 + - ubuntu-2204 + suite: + - chef-workstation + - inspec + - chef-server + - chef-automatev2 + exclude: + - os: centos-7 + suite: chef-server + - os: ubuntu-2204 + suite: chef-server + fail-fast: false + steps: + - name: Check out code + uses: actions/checkout@main + - name: Install Chef + uses: actionshub/chef-install@main + - name: Test-Kitchen Converge + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: converge + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.dokken.yml + continue-on-error: false + - name: Test-Kitchen Verify + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: verify + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.dokken.yml + + + integration-windows-2016: + runs-on: windows-2016 + strategy: + matrix: + os: + - windows-2016 + suite: + - chef-workstation + - inspec + fail-fast: false + steps: + - name: Check windows Version + run: systeminfo + - name: Check out code + uses: actions/checkout@main + - name: Install Chef + uses: actionshub/chef-install@main + - name: Test-Kitchen Converge + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: converge + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + continue-on-error: false + - name: Test-Kitchen Verify + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: verify + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + + integration-windows-2019: + runs-on: windows-2019 + strategy: + matrix: + os: + - windows-2019 + suite: + - chef-workstation + - inspec + fail-fast: false + steps: + - name: Check windows Version + run: systeminfo + - name: Check out code + uses: actions/checkout@main + - name: Install Chef + uses: actionshub/chef-install@main + - name: Test-Kitchen Converge + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: converge + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + continue-on-error: false + - name: Test-Kitchen Verify + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: verify + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + + integration-windows-2022: + runs-on: windows-2022 + strategy: + matrix: + os: + - windows-2022 + suite: + - chef-workstation + - inspec + fail-fast: false + steps: + - name: Check windows Version + run: systeminfo + - name: Check out code + uses: actions/checkout@main + - name: Install Chef + uses: actionshub/chef-install@main + - name: Test-Kitchen Converge + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: converge + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + continue-on-error: false + - name: Test-Kitchen Verify + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: verify + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + + integration-macos-latest: + runs-on: macos-latest + strategy: + matrix: + os: + - macos-latest + suite: + - chef-workstation + - inspec + fail-fast: false + steps: + - name: Check macOS Version + run: sw_vers + - name: Check out code + uses: actions/checkout@main + - name: Install Chef + uses: actionshub/chef-install@main + - name: Test-Kitchen Converge + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: converge + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + continue-on-error: false + - name: Test-Kitchen Verify + uses: actionshub/test-kitchen@main + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + action: verify + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.exec.yml + + check: + if: always() + needs: + - markdownlint + - yamllint + - jsonlint + - cookstylelint + - integration-dokken + - integration-windows-2016 + - integration-windows-2019 + - integration-windows-2022 + - integration-macos-latest + runs-on: Ubuntu-latest + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@main + with: + allowed-failures: + allowed-skips: + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/delivery.yml b/.github/workflows/delivery.yml deleted file mode 100644 index 628af88e..00000000 --- a/.github/workflows/delivery.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: delivery - -on: [push, pull_request] - -jobs: - delivery: - - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@master - - name: Run Chef Delivery - uses: actionshub/chef-delivery@main - env: - CHEF_LICENSE: accept-no-persist diff --git a/.mdlrc b/.mdlrc new file mode 100644 index 00000000..b7e08259 --- /dev/null +++ b/.mdlrc @@ -0,0 +1 @@ +rules "~MD013" diff --git a/.rubocop.yml b/.rubocop.yml index de89e5a4..2c347c42 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,2 +1,3 @@ +--- AllCops: - TargetChefVersion: 13.0 + TargetChefVersion: 17.0 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a1536484..00000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -addons: - apt: - sources: - - chef-current-xenial - packages: - - chef-workstation - -install: echo "skip bundle install" - -env: - - CHEF_LICENSE=accept - -branches: - only: - - master - -services: docker - -env: - matrix: - - INSTANCE=chefdk-debian-9 - - INSTANCE=chefdk-debian-10 - - INSTANCE=chefdk-centos-6 - - INSTANCE=chefdk-centos-7 - - INSTANCE=chefdk-centos-8 - - INSTANCE=chefdk-centos-7 CHEF_VERSION=13 - - INSTANCE=chefdk-centos-7 CHEF_VERSION=14 - - INSTANCE=chefdk-ubuntu-1604 - - INSTANCE=chefdk-ubuntu-1804 - - INSTANCE=chefdk-ubuntu-2004 - - INSTANCE=chefdk-ubuntu-1604 CHEF_VERSION=13 - - INSTANCE=chefdk-ubuntu-1604 CHEF_VERSION=14 - -before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - eval "$(chef shell-init bash)" - - chef --version - -script: KITCHEN_LOCAL_YAML=kitchen.dokken.yml kitchen verify ${INSTANCE} - -matrix: - include: - - script: - - delivery local all - env: - - UNIT_AND_LINT=1 - - CHEF_LICENSE=accept diff --git a/Berksfile b/Berksfile deleted file mode 100644 index 1978348f..00000000 --- a/Berksfile +++ /dev/null @@ -1,6 +0,0 @@ -source 'https://supermarket.chef.io' - -metadata - -cookbook 'test', path: './test/fixtures/cookbooks/test' -cookbook 'custom_repo', path: './test/fixtures/cookbooks/custom_repo' diff --git a/CHANGELOG.md b/CHANGELOG.md index b3e151ad..6d3dd040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ This file is used to list changes made in each version of the chef-ingredient cookbook. +## 3.5.0 (2022-07-28) + +- Added attribute to specify mixlib-install version, defaults to nil to install latest version - [@stromweld](https://github.com/stromweld) +- Fixed automatev2 resource guard and made it idempotent - [@stromweld](https://github.com/stromweld) +- Fixed automatev2 resource to work with debian and rhel family bin locations - [@stromweld](https://github.com/stromweld) +- Updated testing and switched to Github actions for CI pipeline - [@stromweld](https://github.com/stromweld) + ## 3.4.0 (2021-08-05) - Enable `unified_mode` for Chef 17 compatibility - [@detjensrobert](https://github.com/detjensrobert) @@ -183,8 +190,8 @@ This file is used to list changes made in each version of the chef-ingredient co - Remove `chef_server_ingredient` resource shim - Update mixlib-install to major version 3 - - `platform_version_compatibility_mode` property no longer has a default value - - If no matching artifacts are found a `Mixlib::Install::Backend::ArtifactsNotFound` exception is raised instead a `RuntimeError` +- `platform_version_compatibility_mode` property no longer has a default value +- If no matching artifacts are found a `Mixlib::Install::Backend::ArtifactsNotFound` exception is raised instead a `RuntimeError` - All resources have been converted to custom resources ## 1.1.0 (2017-03-01) @@ -232,74 +239,74 @@ This file is used to list changes made in each version of the chef-ingredient co - Swap the Policyfile for a Berksfile - Remove unnecessary action and default_action properties from the custom resources -# v0.19.0 +## v0.19.0 - Remove delivery-cli examples and tests (we now shipit with ChefDK) - Set version constraint to ~> 1.1 for installing mixlib-install from Rubygems -# v0.18.5 +## v0.18.5 - [#106](https://github.com/chef-cookbooks/chef-ingredient/pull/106) Limit `remote_file` backups to 1 - [#110](https://github.com/chef-cookbooks/chef-ingredient/pull/110) Get rid of default: nil warnings -# v0.18.4 +## v0.18.4 - Add `platform_version_compatibility_mode` property to `chef_ingredient` which makes chef-ingredient select packages built for earlier version of a platform during install when a package does not exist for the current platform version. -# v0.18.3 +## v0.18.3 - Add `accept_license` property to `chef_ingredient` which can accept license for Chef products when applicable. -# v0.18.2 +## v0.18.2 - Set version constraint to ~> 1.0 for installing mixlib-install from Rubygems -# v0.18.1 +## v0.18.1 - Bump mixlib-install version to 1.0.6 so unstable channel artifacts won't include metadata.json files. -# v0.18.0 +## v0.18.0 - [#85](https://github.com/chef-cookbooks/chef-ingredient/pull/85) Ability to support unstable channel for all products / platforms. - [#90](https://github.com/chef-cookbooks/chef-ingredient/pull/90) Use packages from packages.chef.io instead of package cloud & remove packagecloud repository setup. - [#91](https://github.com/chef-cookbooks/chef-ingredient/pull/91) Deprecate chef-ha, chef-marketplace, chef-sync, push-client, push-server in favor of ha, marketplace, sync, push-jobs-client, push-jobs-server. -# v0.17.0 +## v0.17.0 - [#77](https://github.com/chef-cookbooks/chef-ingredient/pull/77) Enable installation of chef and chefdk from unstable - [#82](https://github.com/chef-cookbooks/chef-ingredient/pull/82) Set `--force-yes` for older Debian/Ubuntu -# v0.16.0 +## v0.16.0 - [#62](https://github.com/chef-cookbooks/chef-ingredient/issues/62) Do not assume connection to the internet, allow custom recipe for a local repository - [#75](https://github.com/chef-cookbooks/chef-ingredient/pull/75) omnitruck handler windows implementation -# v0.15.0 +## v0.15.0 - [#66](https://github.com/chef-cookbooks/chef-ingredient/pull/66) Fix push job client and server naming - [#68](https://github.com/chef-cookbooks/chef-ingredient/pull/68) Use mixlib-install while installing / upgrading packages from omnitruck - [#71](https://github.com/chef-cookbooks/chef-ingredient/pull/71) Convert `omnibus_service` and `ingredient_config` to "12.5 [custom resources](https://docs.chef.io/custom_resources.html)" - [#73](https://github.com/chef-cookbooks/chef-ingredient/pull/73) Use PRODUCT_MATRIX from mixlib-install -# v0.14.0 +## v0.14.0 - [#58](https://github.com/chef-cookbooks/chef-ingredient/pull/58) Add Chef Compliance product -# v0.13.1 +## v0.13.1 - [#57](https://github.com/chef-cookbooks/chef-ingredient/pull/57) Content accumulator guard -# v0.13.0 +## v0.13.0 - [#56](https://github.com/chef-cookbooks/chef-ingredient/pull/56) Uncomment `use_inline_resources`, this is required for the providers to work properly - [#55](https://github.com/chef-cookbooks/chef-ingredient/pull/55) Remove unit tests for specifically the custom resources - [#54](https://github.com/chef-cookbooks/chef-ingredient/pull/54) Clarify maintainer/support in the README -# v0.12.1 +## v0.12.1 - [#53](https://github.com/chef-cookbooks/chef-ingredient/pull/53) Relax version constraints -# v0.12.0 +## v0.12.0 - Refactor `chef_ingredient` and prepare to handle install/upgrade from omnitruck - Add channel property to `chef_ingredient` @@ -307,100 +314,100 @@ This file is used to list changes made in each version of the chef-ingredient co - Use `product_name` instead of `package_name` - Add not if to skip `ingredient_config` render if `config` property isn't used -# v0.11.3 +## v0.11.3 - Remove `resource_name` from Provider because `:facepalm:` -# v0.11.2 +## v0.11.2 - Add `repository` and `master_token` properties to `chef_server_ingredient` shim for compatibility -# v0.11.1 +## v0.11.1 - [#37](https://github.com/chef-cookbooks/chef-ingredient/issues/37) use `define_matchers` for ChefSpec -# v0.11.0 +## v0.11.0 - [#35](https://github.com/chef-cookbooks/chef-ingredient/issues/35) Add `fqdn_resolves?` method for `chef-server` cookbook. -# v0.10.2 +## v0.10.2 - Add `:add` action to `ingredient_config` -# v0.10.1 +## v0.10.1 - [#30](https://github.com/chef-cookbooks/chef-ingredient/issues/30) Supermarket doesn't use supermarket.rb for configuration, it's supermarket.json -# v0.10.0 +## v0.10.0 - [#23](https://github.com/chef-cookbooks/chef-ingredient/pull/23) Add Chef Marketplace - [#29](https://github.com/chef-cookbooks/chef-ingredient/pull/29) Fix RSpec and noisy warnings -# v0.9.1 +## v0.9.1 - [#26](https://github.com/chef-cookbooks/chef-ingredient/issues/26) Remove mode, owner, and group properties from `ingredient_config`'s resources to prevent resource updates after running ctl commands that manage those file permissions. -# v0.9.0 +## v0.9.0 - Add sensitive property to `ingredient_config` - Use recipe DSL to set resource name -# v0.8.1 +## v0.8.1 - Update PRODUCT_MATRIX.md with correct updated Chef Push product names (push-server, push-client). The code was updated but not the document. -# v0.8.0 +## v0.8.0 - [#7](https://github.com/chef-cookbooks/chef-ingredient/issues/7) Add `ingredient_config` resource - [#10](https://github.com/chef-cookbooks/chef-ingredient/pull/10) Add upgrade action for `chef_ingredient` - Test cleanup, various rubocop fixes -# v0.7.0 +## v0.7.0 - [#3](https://github.com/chef-cookbooks/chef-ingredient/issues/3) Allow :latest as a version - Removes the `package_name` property from the `chef_ingredient` resource, long live `product_name` -# v0.6.0 +## v0.6.0 **Breaking changes** This version is backwards-incompatible with previous versions. We're still sub-1.0, but those who wish to use the `chef_server_ingredient` resource really should pin to version 0.5.0. - [#1](https://github.com/chef-cookbooks/chef-ingredient/issues/1) Use product names instead of package names. -# v0.5.0 +## v0.5.0 - Major refactor and rename. It's fine, this is a new cookbook! -# v0.4.0 (2015-06-11) +## v0.4.0 (2015-06-11) - Add timeout attribute to `chef_server_ingredient` - Use `declare_resource` DSL method to select local package resource - Allow specifying the repository name for the packagecloud repo -# v0.3.2 (2015-04-15) +## v0.3.2 (2015-04-15) - adding proxy support for packagecloud -# v0.3.1 (2015-04-09) +## v0.3.1 (2015-04-09) - Various refactoring and cleanup -# v0.3.0 +## v0.3.0 - Add ctl command for supermarket -# v0.2.0 +## v0.2.0 - Add reconfigure property to ingredient resource -# v0.1.0 +## v0.1.0 - Release this cookbook to Supermarket -# v0.0.2 +## v0.0.2 - #4: define the installed attribute - #1, #2, use packagecloud cookbook -# v0.0.1 +## v0.0.1 - Initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef2f2b80..0943d17c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,2 +1,2 @@ Please refer to -https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD + diff --git a/Policyfile.rb b/Policyfile.rb new file mode 100644 index 00000000..b1fe448a --- /dev/null +++ b/Policyfile.rb @@ -0,0 +1,26 @@ +# Policyfile.rb - Describe how you want Chef Infra Client to build your system. +# +# For more information on the Policyfile feature, visit +# https://docs.chef.io/policyfile/ + +# A name that describes what the system you're building with Chef does. +name 'chef-ingredient' + +# Where to find external cookbooks: +default_source :supermarket + +# run_list: chef-client will run these recipes in the order specified. +run_list 'chef-ingredient::default' +named_run_list :test, 'test' +named_run_list :test_install_git, 'test::install_git' +named_run_list :test_repo, %w(test::install_git test test::repo) +named_run_list :test_local, %w(test::install_git test test::local) +named_run_list :test_chef_workstation, 'test::chef_workstation' +named_run_list :test_inspec,'test::inspec' +named_run_list :test_chef_server, 'test::chef_server_noaddons' +named_run_list :test_chef_automatev2, 'test::automatev2' + +# Specify a custom source for a single cookbook: +cookbook 'chef-ingredient', path: '.' +cookbook 'test', path: './test/fixtures/cookbooks/test' +cookbook 'custom_repo', path: './test/fixtures/cookbooks/custom_repo' diff --git a/README.md b/README.md index 836b8818..8d4eea53 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ It will perform component installation and configuration. It provides no recipes - Ubuntu - Debian -- CentOS/RHEL +- CentOS/RHEL/Almalinux/Rockylinux - openSUSE - Amazon Linux ### Chef Infra -- Chef Infra Client 13.0 +- Chef Infra Client 15.3 ### Cookbooks @@ -38,7 +38,7 @@ A "chef ingredient" is the core package itself, or products or add-on components By default, `chef_ingredient` will install using the `packages.chef.io` stable repository depending on the platform. However, it can be configured to use a custom repository by setting the `node['chef-ingredient']['custom-repo-recipe']` attribute (nil by default). -#### Actions +#### chef_ingredient Actions - `install` - (default) Configures the package repository and installs the specified package. - `upgrade` - Upgrades the specified package. @@ -46,7 +46,7 @@ By default, `chef_ingredient` will install using the `packages.chef.io` stable r - `remove` - Alias for uninstall - `reconfigure` - Performs the `ctl reconfigure` command for the package. -#### Properties +#### chef_ingredient Properties - `product_name` - The product name. See the [PRODUCT_MATRIX.md](https://github.com/chef/mixlib-install/blob/master/PRODUCT_MATRIX.md). For example, `chef-server`, `analytics`, `delivery`, `manage`, etc. - `config` - content that will be added to the configuration file of the given product. @@ -67,11 +67,11 @@ By default, `chef_ingredient` will install using the `packages.chef.io` stable r Manages a sub-service within the context of a Chef product package. For example the `rabbitmq` service that is run for the Chef Server. -#### Actions +#### omnibus_service Actions This delegates to the ctl command the service management command specified in the action. Not all the service management commands are supported, however, as not all of them would make sense when used in a recipe. This resource is primarily used for sending or receiving notifications. See the example section. -#### Properties +#### omnibus_service Properties - `service_name` - The name of the service to manage. Specify this like `product_name/service`, for example, `chef-server/rabbitmq`. - `ctl_command` - The "ctl" command, e.g. `chef-server-ctl`. This should be automatically detected by the library helper method `chef_ctl_command`, but may need to be specified if something changes, like a new add-on is made available. @@ -80,18 +80,18 @@ This delegates to the ctl command the service management command specified in th Makes it easy to create update configuration files of each Chef product. It uses the default locations for each product. -#### Actions +#### ingredient_config Actions - `render` - (default) Creates the configuration file using the options passed in via `add` action or `config` attribute of `chef_ingredient` resource. - `add` - Adds the `config` attribute contents to the data collection. Must run `:render` action to generate the file. -#### Properties +#### ingredient_config Properties - `product_name` - The product name. See the [PRODUCT_MATRIX.md](https://github.com/chef/mixlib-install/blob/master/PRODUCT_MATRIX.md). For example, `chef-server`, `analytics`, `delivery`, `manage`, etc. - `config` - Content that will be added to the configuration file of the given product. - `sensitive` - Set to mask the config contents in logs. Use when you config contains information like passwords or secrets. -#### Examples +#### ingredient_config Examples We may need to restart the RabbitMQ service on the Chef Server, for example when adding configuration for Chef Analytics. @@ -164,7 +164,7 @@ These properties exist for all infrastructure resources Installs Chef Automate. -#### Properties +#### chef_automate Properties - `enterprise` - The Enterprise to create in Automate - `license` - we recommend using the chef_file resource @@ -177,14 +177,14 @@ Installs Chef Automate. Installs Chef Automate version 2 -#### Requirements +#### chef_automatev2 Requirements - Requires chef-client 14+ due to use of sysctl resource - General Properties used ### chef_backend -#### Properties +#### chef_backend Properties - `bootstrap_node` - The node we'll bootstrap secrets with. - `publish_address` - node['ipaddress'] | The address you want Chef-Backend to listen on. @@ -194,7 +194,7 @@ Installs Chef Automate version 2 ### chef_org -#### Properties +#### chef_org Properties - `org` - The short name of the org. - `org_full_name` - The full name of the org you want to create. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 9b54eed7..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -environment: - machine_user: vagrant - machine_pass: vagrant - CHEF_LICENSE: accept - KITCHEN_YAML: kitchen.appveyor.yml - - matrix: - - CHEF_VERSION: 15 - - CHEF_VERSION: 16 - -# don't build PRs twice -branches: - only: - - master - -# Do not build on tags (GitHub only) -skip_tags: true - -#faster cloning -clone_depth: 1 - -# Install the latest current build of Chef Workstation -install: - - ps: iex (irm https://omnitruck.chef.io/install.ps1); Install-Project -Project chef-workstation -channel stable - - ps: 'Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version' - - ps: $PSVersionTable - - ps: secedit /export /cfg $env:temp/export.cfg - - ps: ((get-content $env:temp/export.cfg) -replace ('PasswordComplexity = 1', 'PasswordComplexity = 0')) | Out-File $env:temp/export.cfg - - ps: ((get-content $env:temp/export.cfg) -replace ('MinimumPasswordLength = 8', 'MinimumPasswordLength = 0')) | Out-File $env:temp/export.cfg - - ps: secedit /configure /db $env:windir/security/new.sdb /cfg $env:temp/export.cfg /areas SECURITYPOLICY - - ps: net user /add $env:machine_user $env:machine_pass - - ps: net localgroup administrators $env:machine_user /add - -build_script: - - ps: $env:PATH = "$env:PATH;c:\opscode\chef-workstation\bin\"; $env:CHEFWS_ENV_FIX = 1 - - ps: c:\opscode\chef-workstation\bin\chef.exe shell-init powershell | iex; cmd /c c:\opscode\chef-workstation\bin\chef.exe --version - -test_script: - - chef --version - - chef.exe exec delivery local all - - chef.exe exec kitchen verify - -deploy: off diff --git a/attributes/default.rb b/attributes/default.rb index 383e4aaf..bca2394e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -32,3 +32,4 @@ # a revision, branch or tag. # default['chef-ingredient']['mixlib-install']['git_ref'] = nil +default['chef-ingredient']['mixlib-install']['version'] = nil # nil installs latest diff --git a/kitchen.appveyor.yml b/kitchen.appveyor.yml deleted file mode 100644 index 20f8b013..00000000 --- a/kitchen.appveyor.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -driver: - name: proxy - host: localhost - reset_command: "exit 0" - port: 5985 - username: <%= ENV["machine_user"] %> - password: <%= ENV["machine_pass"] %> - -transport: - name: winrm - elevated: true - -provisioner: - name: chef_zero - deprecations_as_errors: true - chef_license: accept-no-persist - -platforms: - - name: windows-2012R2 - -suites: - - name: inspec - run_list: - - recipe[test::inspec] diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 391f801b..0d52809c 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -1,3 +1,4 @@ +--- driver: name: dokken privileged: true # because Docker and SystemD/Upstart @@ -11,6 +12,8 @@ provisioner: name: dokken data_bags_path: test/fixtures/data_bags deprecations_as_errors: true + always_update_cookbooks: true + clean_dokken_sandbox: false client_rb: silence_deprecation_warnings: - chef-25 @@ -19,35 +22,35 @@ verifier: name: inspec platforms: - - name: amazonlinux + - name: almalinux-8 driver: - image: dokken/amazonlinux - pid_one_command: /sbin/init + image: dokken/almalinux-8 + pid_one_command: /usr/lib/systemd/systemd + + - name: almalinux-9 + driver: + image: dokken/almalinux-9 + pid_one_command: /usr/lib/systemd/systemd - name: amazonlinux-2 driver: image: dokken/amazonlinux-2 pid_one_command: /usr/lib/systemd/systemd - - name: debian-9 + - name: debian-10 driver: - image: dokken/debian-9 + image: dokken/debian-10 pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update - - name: debian-10 + - name: debian-11 driver: - image: dokken/debian-10 + image: dokken/debian-11 pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update - - name: centos-6 - driver: - image: dokken/centos-6 - pid_one_command: /sbin/init - - name: centos-7 driver: image: dokken/centos-7 @@ -63,13 +66,6 @@ platforms: image: dokken/fedora-latest pid_one_command: /usr/lib/systemd/systemd - - name: ubuntu-16.04 - driver: - image: dokken/ubuntu-16.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - - name: ubuntu-18.04 driver: image: dokken/ubuntu-18.04 @@ -84,18 +80,14 @@ platforms: intermediate_instructions: - RUN /usr/bin/apt-get update + - name: ubuntu-22.04 + driver: + image: dokken/ubuntu-22.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + - name: opensuse-leap-15 driver: image: dokken/opensuse-leap-15 pid_one_command: /bin/systemd - -suites: - - name: chef-workstation - run_list: - - recipe[test] - - recipe[test::chef_workstation] - - - name: rubygems-url - run_list: - - recipe[test] - - recipe[test::rubygems_url] diff --git a/kitchen.exec.yml b/kitchen.exec.yml new file mode 100644 index 00000000..bddc73ce --- /dev/null +++ b/kitchen.exec.yml @@ -0,0 +1,15 @@ +--- +driver: + name: exec + gui: false + customize: + memory: 4096 + +transport: + name: exec + +platforms: + - name: windows-2016 + - name: windows-2019 + - name: windows-2022 + - name: macos-latest diff --git a/kitchen.yml b/kitchen.yml index 9260f10d..6a4b161f 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -1,3 +1,4 @@ +--- driver: name: vagrant customize: @@ -6,9 +7,10 @@ driver: provisioner: require_chef_omnibus: <%= ENV['CHEF_VERSION'] || true %> - name: chef_zero + name: chef_infra data_bags_path: test/fixtures/data_bags deprecations_as_errors: true + always_update_cookbooks: true retry_on_exit_code: - 213 max_retries: 1 @@ -24,93 +26,68 @@ verifier: name: inspec platforms: - - name: amazonlinux - driver_config: - box: mvbcoding/awslinux + - name: almalinux-8 + - name: almalinux-9 - name: amazonlinux-2 - - name: centos-6 - name: centos-7 - name: centos-8 - - name: debian-9 - name: debian-10 + - name: debian-11 - name: fedora-latest - name: freebsd-12 + - name: freebsd-13 - name: opensuse-leap-15 - - name: ubuntu-16.04 + - name: rockylinux-8 + - name: rockylinux-9 - name: ubuntu-18.04 - name: ubuntu-20.04 + - name: ubuntu-22.04 - name: macos-10.12 driver: box: chef/macos-10.12 # private - - name: windows-server-2012r2 + - name: macos-latest # Used for CI pipeline + - name: windows-2016 driver: - box: tas50/windows_2012r2 + box: stromweld/windows-2016 customize: cpus: 4 - - name: windows-server-2016 + - name: windows-2019 driver_config: - box: tas50/windows_2016 + box: stromweld/windows-2019 + customize: + cpus: 4 + - name: windows-2022 + driver_config: + box: stromweld/windows-2022 customize: cpus: 4 - -default: &default - attributes: - chef-ingredient: - mixlib-install: - # Set to install mixlib-install from source - git_ref: <%= ENV['MIXLIB_INSTALL_GIT_REF'] %> suites: - name: default - <<: *default - excludes: [ 'macos-10.12', 'windows-server-2012r2', 'windows-server-2016-standard' ] - run_list: - <% if ENV['MIXLIB_INSTALL_GIT_REF'] %> - - recipe[test::install_git] - <% end %> - - recipe[test] - - recipe[test::repo] + excludes: ['macos-10.12', 'macos-latest', 'windows-2016', 'windows-2019', 'windows-2022'] + named_run_list: test_repo + + - name: local-package-install + excludes: ['macos-10.12', 'macos-latest', 'windows-2016', 'windows-2019', 'windows-2022'] + named_run_list: test_local - - name: local_package_install - <<: *default - excludes: [ 'macos-10.12', 'windows-server-2012r2', 'windows-server-2016-standard' ] - run_list: - - recipe[test] - - recipe[test::local] + - name: rubygems-url + excludes: ['macos-10.12', 'macos-latest', 'windows-2016', 'windows-2019', 'windows-2022'] + named_run_list: test_rubygems_url - - name: chefdk - <<: *default - includes: [ 'ubuntu-16.04', 'ubuntu-18.04', 'ubuntu-20.04', 'centos-6', 'centos-7', 'centos-8', 'macos-10.12', 'windows-server-2012r2', 'windows-server-2016-standard' ] - run_list: - <% if ENV['MIXLIB_INSTALL_GIT_REF'] %> - - recipe[test::install_git] - <% end %> - - recipe[test] - - recipe[test::chefdk] + - name: chef-workstation + named_run_list: test_chef_workstation - name: inspec - <<: *default - includes: [ 'ubuntu-16.04', 'ubuntu-18.04', 'ubuntu-20.04', 'centos-6', 'centos-7', 'centos-8', 'macos-10.12', 'windows-server-2012r2', 'windows-server-2016-standard' ] - run_list: - <% if ENV['MIXLIB_INSTALL_GIT_REF'] %> - - recipe[test::install_git] - <% end %> - - recipe[test] - - recipe[test::inspec] + named_run_list: test_inspec - - name: chef_server - includes: [ 'ubuntu-16.04', 'ubuntu-18.04', 'ubuntu-20.04', 'centos-7', 'centos-8' ] - run_list: - - recipe[test] - - recipe[test::chef_server] + - name: chef-server + includes: ['almalinux-8', 'almalinux-9', 'rockylinux-8', 'rockylinux-9', 'ubuntu-18.04', 'ubuntu-20.04', 'ubuntu-22.04', 'centos-7', 'centos-8'] + named_run_list: test_chef_server - - name: chef_automatev2 + - name: chef-automatev2 driver: customize: memory: 2560 - includes: [ 'ubuntu-16.04', 'ubuntu-18.04', 'ubuntu-20.04', 'centos-7', 'centos-8' ] - run_list: - - recipe[test::automatev2] - verifier: - inspec_tests: - - test/integration/chef_automatev2 + includes: ['almalinux-8', 'almalinux-9', 'rockylinux-8', 'rockylinux-9', 'ubuntu-18.04', 'ubuntu-20.04', 'ubuntu-22.04', 'centos-7', 'centos-8'] + named_run_list: test_chef_automatev2 diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 8f36c215..be08e07f 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -68,7 +68,7 @@ def ingredient_config_file(product_name) # def ensure_mixlib_versioning_gem_installed! node.run_state[:mixlib_versioning_gem_installed] ||= begin - install_gem_from_rubygems('mixlib-versioning', '~> 1.1') + install_gem_from_rubygems('mixlib-versioning') require 'mixlib/versioning' true @@ -87,7 +87,7 @@ def ensure_mixlib_install_gem_installed! 'mixlib-install' ) else - install_gem_from_rubygems('mixlib-install', '~> 3.3') + install_gem_from_rubygems('mixlib-install', node['chef-ingredient']['mixlib-install']['version']) end require 'mixlib/install' @@ -99,11 +99,11 @@ def ensure_mixlib_install_gem_installed! # # Helper method to install a gem from rubygems at compile time. # - def install_gem_from_rubygems(gem_name, gem_version) - Chef::Log.debug("Installing #{gem_name} v#{gem_version} from #{new_resource.rubygems_url}") + def install_gem_from_rubygems(gem_name, gem_version = nil) + Chef::Log.debug("Installing #{gem_name}#{" v#{gem_version}" if gem_version} from #{new_resource.rubygems_url}") chefgem = Chef::Resource::ChefGem.new(gem_name, run_context) chefgem.source(new_resource.rubygems_url) if new_resource.rubygems_url - chefgem.version(gem_version) + chefgem.version(gem_version) if gem_version chefgem.run_action(:install) end diff --git a/metadata.rb b/metadata.rb index 74e1ba6d..4a36457f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ maintainer_email 'cookbooks@chef.io' license 'Apache-2.0' description 'Primitives for managing Chef products and packages' -version '3.4.0' +version '3.5.0' %w(amazon centos redhat scientific oracle fedora debian ubuntu).each do |os| supports os @@ -12,4 +12,4 @@ source_url 'https://github.com/chef-cookbooks/chef-ingredient' issues_url 'https://github.com/chef-cookbooks/chef-ingredient/issues' -chef_version '>= 13.0' +chef_version '>= 15.3' diff --git a/resources/automatev2.rb b/resources/automatev2.rb index f6f4e2f0..2004fe23 100644 --- a/resources/automatev2.rb +++ b/resources/automatev2.rb @@ -26,10 +26,15 @@ property :products, Array, default: ['automate'] action :create do + bin_path = value_for_platform_family( + debian: '/bin/chef-automate', + default: '/usr/bin/chef-automate' + ) + execute "curl https://packages.chef.io/files/#{new_resource.channel}/#{new_resource.version}/chef-automate-cli/chef-automate_linux_amd64.zip | gunzip - > chef-automate && chmod +x chef-automate" do cwd '/usr/local/bin' creates '/usr/local/bin/chef-automate' - not_if { FileTest.file?('/usr/bin/chef-automate') } + not_if { FileTest.file?(bin_path) } end ## TODO: add dependancy on sysctl cookbook unless chef-client v14.0+ @@ -44,12 +49,14 @@ execute '/usr/local/bin/chef-automate init-config' do cwd Chef::Config[:file_cache_path] creates "#{Chef::Config[:file_cache_path]}/config.toml" + only_if { FileTest.file?('/usr/local/bin/chef-automate') } end execute "/usr/local/bin/chef-automate deploy #{Chef::Config[:file_cache_path]}/config.toml --product #{new_resource.products.join(' --product ')}#{' --accept-terms-and-mlsa' if new_resource.accept_license}" do cwd Chef::Config[:file_cache_path] + live_stream true only_if { FileTest.file?("#{Chef::Config[:file_cache_path]}/config.toml") } - not_if 'chef-automate service-versions' + not_if { FileTest.file?(bin_path) && shell_out("#{bin_path} service-versions").exitstatus.eql?(0) } end file "#{Chef::Config[:file_cache_path]}/custom_config.toml" do @@ -59,8 +66,9 @@ execute "chef-automate config patch #{Chef::Config[:file_cache_path]}/custom_config.toml" do cwd Chef::Config[:file_cache_path] + live_stream true action :nothing - only_if { FileTest.file?('/usr/bin/chef-automate') } + only_if { FileTest.file?(bin_path) } end file '/usr/local/bin/chef-automate' do @@ -73,6 +81,11 @@ end action :reconfigure do + bin_path = value_for_platform_family( + debian: '/bin/chef-automate', + default: '/usr/bin/chef-automate' + ) + file "#{Chef::Config[:file_cache_path]}/custom_config.toml" do content new_resource.config notifies :run, "execute[chef-automate config patch #{Chef::Config[:file_cache_path]}/custom_config.toml]", :immediately @@ -80,7 +93,8 @@ execute "chef-automate config patch #{Chef::Config[:file_cache_path]}/custom_config.toml" do cwd Chef::Config[:file_cache_path] + live_stream true action :nothing - only_if { FileTest.file?('/usr/bin/chef-automate') } + only_if { FileTest.file?(bin_path) } end end diff --git a/spec/unit/metadata.rb b/spec/unit/metadata.rb index 8feb43ab..b8ecfea7 100644 --- a/spec/unit/metadata.rb +++ b/spec/unit/metadata.rb @@ -1 +1,2 @@ name 'FC045-not-a-cookbook' +version '0.0.1' diff --git a/test/fixtures/cookbooks/test/recipes/automatev2.rb b/test/fixtures/cookbooks/test/recipes/automatev2.rb index 5050e5ae..db4af9aa 100644 --- a/test/fixtures/cookbooks/test/recipes/automatev2.rb +++ b/test/fixtures/cookbooks/test/recipes/automatev2.rb @@ -3,5 +3,6 @@ [global.v1] fqdn = "chef-automate.example.com" EOS + products %w(automate infra-server builder desktop) accept_license true end diff --git a/test/fixtures/cookbooks/test/recipes/chef_server_noaddons.rb b/test/fixtures/cookbooks/test/recipes/chef_server_noaddons.rb index 0e5ef3ee..e920290c 100644 --- a/test/fixtures/cookbooks/test/recipes/chef_server_noaddons.rb +++ b/test/fixtures/cookbooks/test/recipes/chef_server_noaddons.rb @@ -1,3 +1,8 @@ -chef_server 'chef-server.local' do - config '' +node.default['chef_server']['fqdn'] = 'localhost' + +chef_server node['chef_server']['fqdn'] do + config <<-EOS +api_fqdn '#{node['chef_server']['fqdn']}' + EOS + accept_license true end diff --git a/test/fixtures/cookbooks/test/recipes/chef_workstation.rb b/test/fixtures/cookbooks/test/recipes/chef_workstation.rb index aadb65d1..25bb01f9 100644 --- a/test/fixtures/cookbooks/test/recipes/chef_workstation.rb +++ b/test/fixtures/cookbooks/test/recipes/chef_workstation.rb @@ -1,13 +1,4 @@ -chef_ingredient 'install old chef-workstation version' do +chef_ingredient 'install chef-workstation' do product_name 'chef-workstation' - action :install - version '0.18.3' - platform_version_compatibility_mode true -end - -chef_ingredient 'upgrade to newer chef-workstation version' do - product_name 'chef-workstation' - action :upgrade - version '21.1.247' platform_version_compatibility_mode true end diff --git a/test/fixtures/cookbooks/test/recipes/inspec.rb b/test/fixtures/cookbooks/test/recipes/inspec.rb index 944b52da..553babcc 100644 --- a/test/fixtures/cookbooks/test/recipes/inspec.rb +++ b/test/fixtures/cookbooks/test/recipes/inspec.rb @@ -1,12 +1,4 @@ -chef_ingredient 'install old inspec version' do +chef_ingredient 'install inspec version' do product_name 'inspec' - version '1.30.0' - platform_version_compatibility_mode true -end - -chef_ingredient 'upgrade to newer inspec version' do - product_name 'inspec' - action :upgrade - version '1.31.1' platform_version_compatibility_mode true end diff --git a/test/integration/chef_automatev2/test_chef_automatev2_spec.rb b/test/integration/chef-automatev2/test_chef_automatev2_spec.rb similarity index 50% rename from test/integration/chef_automatev2/test_chef_automatev2_spec.rb rename to test/integration/chef-automatev2/test_chef_automatev2_spec.rb index 5c939fdd..619fd272 100644 --- a/test/integration/chef_automatev2/test_chef_automatev2_spec.rb +++ b/test/integration/chef-automatev2/test_chef_automatev2_spec.rb @@ -2,6 +2,20 @@ # its('exit_status') { should eq 0 } # end +describe file('/usr/local/bin/chef-automate') do + it { should_not exist } +end + +bin_path = if os.debian? + '/bin/chef-automate' + else + '/usr/bin/chef-automate' + end + +describe file(bin_path) do + it { should exist } +end + describe command('chef-automate version') do its('exit_status') { should eq 0 } end diff --git a/test/integration/chef_server/test_chef_server_spec.rb b/test/integration/chef-server/test_chef_server_spec.rb similarity index 100% rename from test/integration/chef_server/test_chef_server_spec.rb rename to test/integration/chef-server/test_chef_server_spec.rb diff --git a/test/integration/chef-workstation/test_chef_workstation_spec.rb b/test/integration/chef-workstation/test_chef_workstation_spec.rb index 7e90af37..a0124ef2 100644 --- a/test/integration/chef-workstation/test_chef_workstation_spec.rb +++ b/test/integration/chef-workstation/test_chef_workstation_spec.rb @@ -3,16 +3,6 @@ # has not been reloaded. This reloads $env:Path before calling the program. I could see this being beneficial to # inspec's default behavior. -resource_command = 'command' - -if os.windows? - resource_command = 'powershell' - - describe powershell('$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")') do - its('exit_status') { should eq 0 } - end -end - -describe send(resource_command, 'chef --version') do - its('stdout') { should match(/Chef Workstation version: 21\.1\.247/) } -end +describe package('chef-workstation') do + it { should be_installed } +end unless os.windows? || os.darwin? diff --git a/test/integration/inspec/inspec_spec.rb b/test/integration/inspec/inspec_spec.rb index ea35d9c7..45e27677 100644 --- a/test/integration/inspec/inspec_spec.rb +++ b/test/integration/inspec/inspec_spec.rb @@ -3,16 +3,6 @@ # has not been reloaded. This reloads $env:Path before calling the program. I could see this being beneficial to # inspec's default behavior. -resource_command = 'command' - -if os.windows? - resource_command = 'powershell' - - describe powershell('$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")') do - its('exit_status') { should eq 0 } - end -end - -describe send(resource_command, 'inspec --version') do - its('stdout') { should match(/4.22.1/) } -end +describe package('inspec') do + it { should be_installed } +end unless os.windows? || os.darwin? diff --git a/test/integration/local_package_install/assert_local_package_installed_spec.rb b/test/integration/local-package-install/assert_local_package_installed_spec.rb similarity index 100% rename from test/integration/local_package_install/assert_local_package_installed_spec.rb rename to test/integration/local-package-install/assert_local_package_installed_spec.rb