Skip to content

Commit

Permalink
WIP: Update to hab 0.81.0 (#171)
Browse files Browse the repository at this point in the history
Update hab to 0.81.0 and add behaviour to handle new Habitat license requirements

Signed-off-by: Jon Cowie <jonlives@gmail.com>
  • Loading branch information
jonlives committed May 29, 2019
1 parent dcb8b90 commit e563ab8
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 35 deletions.
18 changes: 8 additions & 10 deletions .travis.yml
@@ -1,10 +1,7 @@
sudo: required
dist: trusty

addons:
apt:
sources:
- chef-current-trusty
- chef-current-xenial
packages:
- chefdk

Expand All @@ -19,26 +16,27 @@ services: docker

env:
matrix:
- INSTANCE=package-ubuntu-1404
- INSTANCE=package-ubuntu-1604
- INSTANCE=package-ubuntu-1804
- INSTANCE=package-centos-6
- INSTANCE=package-centos-7
- INSTANCE=service-ubuntu-1404
- INSTANCE=service-ubuntu-1604
- INSTANCE=service-ubuntu-1804
- INSTANCE=service-centos-6
- INSTANCE=service-centos-7
- INSTANCE=sup-ubuntu-1404
- INSTANCE=sup-ubuntu-1604
- INSTANCE=sup-ubuntu-1804
- INSTANCE=sup-centos-6
- INSTANCE=sup-centos-7
- INSTANCE=config-ubuntu-1404
- INSTANCE=config-ubuntu-1604
- INSTANCE=config-ubuntu-1804
- INSTANCE=config-centos-6
- INSTANCE=config-centos-7
- INSTANCE=user-toml-ubuntu-1404
- INSTANCE=user-toml-ubuntu-1604
- INSTANCE=user-toml-ubuntu-1804
- INSTANCE=user-toml-centos-6
- INSTANCE=user-toml-centos-7
- INSTANCE=license-centos-7

before_script:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
Expand All @@ -48,7 +46,7 @@ before_script:
- cookstyle --version
- foodcritic --version

script: KITCHEN_LOCAL_YAML=kitchen.dokken.yml kitchen verify ${INSTANCE}
script: CHEF_LICENSE=accept-no-persist KITCHEN_LOCAL_YAML=kitchen.dokken.yml CHEF_VERSION=${CHEF_VERSION} kitchen verify ${INSTANCE}

matrix:
include:
Expand Down
21 changes: 20 additions & 1 deletion README.md
Expand Up @@ -9,6 +9,23 @@ This cookbook provides resources for working with [Habitat](https://habitat.sh).

(this is a pre-1.0 version, after all)

## License Note

Habitat requires acceptance of a license before any habitat commands can be run. To accept the Habitat license using this cookbook, the `license` parameter can be set to `accept` for either the `hab_install` or `hab_sup` resources as shown in the below examples:

```ruby
hab_install 'install habitat' do
license 'accept
end
```
```ruby
hab_sup 'default' do
license 'accept
end
```

PLEASE NOTE: Without performing one of the above license acceptance steps, all other resources in the habitat cookbook will fail with an error prompting that the license must be accepted.
## Requirements

### Platforms
Expand All @@ -20,7 +37,7 @@ This cookbook provides resources for working with [Habitat](https://habitat.sh).

### Habitat

- Habitat version: 0.79.1
- Habitat version: 0.81.0

This cookbook is developed lockstep with the latest release of Habitat to ensure compatibility, going forward from 0.33.0 of the cookbook and 0.33.2 of Habitat itself. When new versions of Habitat are released, the version should be updated in these files:

Expand Down Expand Up @@ -57,6 +74,7 @@ Installs Habitat on the system using the [install script](https://raw.githubuser
- `bldr_url`: Optional URL to an alternate Builder (defaults to the public Builder)
- `create_user`: Creates the `hab` system user (defaults to `true`)
- `tmp_dir`: Sets TMPDIR environment variable for location to place temp files. (required if `/tmp` and `/var/tmp` are mounted `noexec`)
- `license`: Specifies acceptance of habitat license when set to `accept` (defaults to empty string).

#### Examples

Expand Down Expand Up @@ -208,6 +226,7 @@ The `run` action handles installing Habitat using the `hab_install` resource, en
- `ring`: Only valid for `:run` action, passes `--ring` with the specified ring key name to the hab command
- `hab_channel`: The channel to install Habitat from. Defaults to stable
- `auth_token`: Auth token for accessing a private organization on bldr. This value is templated into the appropriate service file.
- `license`: Specifies acceptance of habitat license when set to `accept` (defaults to empty string).

#### Examples

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.79.1
0.81.0
26 changes: 17 additions & 9 deletions kitchen.dokken.yml
Expand Up @@ -19,6 +19,11 @@ platforms:
image: dokken/amazonlinux
pid_one_command: /sbin/init

- name: amazonlinux-2
driver:
image: dokken/amazonlinux-2
pid_one_command: /usr/lib/systemd/systemd

- name: debian-8
driver:
image: dokken/debian-8
Expand All @@ -36,35 +41,38 @@ platforms:
- name: centos-6
driver:
image: dokken/centos-6
platform: rhel
pid_one_command: /sbin/init

- name: centos-7
driver:
image: dokken/centos-7
platform: rhel
pid_one_command: /usr/lib/systemd/systemd

- name: fedora-latest
driver:
image: dokken/fedora-latest
pid_one_command: /usr/lib/systemd/systemd

- name: ubuntu-14.04
- name: ubuntu-16.04
driver:
image: dokken/ubuntu-14.04
pid_one_command: /sbin/init
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update

- name: ubuntu-16.04
- name: ubuntu-18.04
driver:
image: dokken/ubuntu-16.04
image: dokken/ubuntu-18.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update

- name: opensuse-leap
- name: opensuse-leap-42
driver:
image: dokken/opensuse-leap-42
pid_one_command: /bin/systemd

- name: opensuse-leap-15
driver:
image: dokken/opensuse-leap
image: dokken/opensuse-leap-15
pid_one_command: /bin/systemd
4 changes: 4 additions & 0 deletions kitchen.yml
Expand Up @@ -45,6 +45,10 @@ suites:
run_list: test::user_toml
excludes:
- windows-2016
- name: license
run_list: test::license
excludes:
- windows-2016
- name: win-package
run_list: test::win_package
includes:
Expand Down
4 changes: 2 additions & 2 deletions libraries/habitat_shared.rb
Expand Up @@ -16,8 +16,8 @@

module Habitat
module Shared
HAB_VERSION = '0.79.1'.freeze
LINUX_LAUNCHER_VERSION = '9167'.freeze
HAB_VERSION = '0.81.0'.freeze
LINUX_LAUNCHER_VERSION = '11055'.freeze
WINDOWS_LAUNCHER_VERSION = '8656'.freeze
WINDOWS_SERVICE_VERSION = '0.3.1'.freeze

Expand Down
5 changes: 4 additions & 1 deletion libraries/resource_hab_sup.rb
Expand Up @@ -35,9 +35,12 @@ class HabSup < Resource
property :hab_channel, String
property :auto_update, [true, false], default: false
property :auth_token, String
property :license, String, equal_to: ['accept']

action :run do
hab_install new_resource.name
hab_install new_resource.name do
license new_resource.license
end

hab_package 'core/hab-sup' do
bldr_url new_resource.bldr_url if new_resource.bldr_url
Expand Down
3 changes: 3 additions & 0 deletions resources/install.rb
Expand Up @@ -28,6 +28,7 @@
property :bldr_url, String
property :create_user, [true, false], default: true
property :tmp_dir, String
property :license, String, equal_to: ['accept']

action :install do
if ::File.exist?(hab_path)
Expand Down Expand Up @@ -92,6 +93,8 @@
end
)
end

execute 'hab license accept' if new_resource.license == 'accept'
end
end

Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/cookbooks/test/recipes/config.rb
@@ -1,6 +1,8 @@
apt_update

hab_sup 'default'
hab_sup 'default' do
license 'accept'
end

ruby_block 'wait-for-sup-default-startup' do
block do
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/cookbooks/test/recipes/install_for_chefspec.rb
@@ -1,11 +1,15 @@
# This recipe is used for running the `install_spec` tests, it should
# not be used in the other recipes.
hab_install 'install habitat'
hab_install 'install habitat' do
license 'accept'
end

hab_install 'install habitat with depot url' do
bldr_url 'https://localhost'
license 'accept'
end

hab_install 'install habitat with tmp_dir' do
tmp_dir '/foo/bar'
license 'accept'
end
1 change: 1 addition & 0 deletions test/fixtures/cookbooks/test/recipes/install_no_user.rb
@@ -1,3 +1,4 @@
hab_install 'no-users-here' do
create_user false
license 'accept'
end
3 changes: 3 additions & 0 deletions test/fixtures/cookbooks/test/recipes/license.rb
@@ -0,0 +1,3 @@
hab_install 'install habitat with license accept' do
license 'accept'
end
4 changes: 3 additions & 1 deletion test/fixtures/cookbooks/test/recipes/package.rb
@@ -1,6 +1,8 @@
apt_update

hab_install
hab_install 'default' do
license 'accept'
end

hab_package 'core/redis'

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/cookbooks/test/recipes/service.rb
@@ -1,5 +1,6 @@
hab_sup 'default' do
hab_channel 'stable'
license 'accept'
end

ruby_block 'wait-for-sup-default-startup' do
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/cookbooks/test/recipes/sup.rb
Expand Up @@ -7,6 +7,7 @@

hab_sup 'tester' do
bldr_url 'https://willem.habitat.sh'
license 'accept'
end

ruby_block 'wait-for-sup-default-startup' do
Expand All @@ -18,6 +19,7 @@
end

hab_sup 'test-options' do
license 'accept'
listen_http '0.0.0.0:9999'
listen_gossip '0.0.0.0:9998'
notifies :stop, 'hab_sup[tester]', :before
Expand All @@ -33,6 +35,7 @@
end

hab_sup 'test-auth-token' do
license 'accept'
auth_token 'test'
listen_http '0.0.0.0:10001'
listen_gossip '0.0.0.0:10000'
Expand All @@ -49,6 +52,7 @@
end

hab_sup 'single_peer' do
license 'accept'
listen_http '0.0.0.0:8999'
listen_gossip '0.0.0.0:8998'
peer '127.0.0.2'
Expand All @@ -65,6 +69,7 @@
end

hab_sup 'multiple_peers' do
license 'accept'
peer ['127.0.0.2', '127.0.0.3']
listen_http '0.0.0.0:7999'
listen_gossip '0.0.0.0:7998'
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/cookbooks/test/recipes/user_toml.rb
@@ -1,6 +1,8 @@
apt_update

hab_sup 'default'
hab_sup 'default' do
license 'accept'
end

ruby_block 'wait-for-sup-default-startup' do
block do
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/cookbooks/test/recipes/win_config.rb
@@ -1,4 +1,6 @@
hab_sup 'default'
hab_sup 'default' do
license 'accept'
end

ruby_block 'wait-for-sup-default-startup' do
block do
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/cookbooks/test/recipes/win_package.rb
@@ -1,4 +1,6 @@
hab_install
hab_install 'default' do
license 'accept'
end

hab_package 'skylerto/splunkforwarder' do
version '7.0.3/20180418161444'
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/cookbooks/test/recipes/win_service.rb
@@ -1,4 +1,6 @@
hab_sup 'default'
hab_sup 'default' do
license 'accept'
end

ruby_block 'wait-for-sup-default-startup' do
block do
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/cookbooks/test/recipes/win_sup.rb
@@ -1,4 +1,5 @@
hab_sup 'tester' do
license 'accept'
bldr_url 'https://willem.habitat.sh'
listen_http '0.0.0.0:9999'
listen_gossip '0.0.0.0:9998'
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/cookbooks/test/recipes/win_user_toml.rb
@@ -1,4 +1,6 @@
hab_sup 'default'
hab_sup 'default' do
license 'accept'
end

ruby_block 'wait-for-sup-default-startup' do
block do
Expand Down
2 changes: 1 addition & 1 deletion test/integration/config/default_spec.rb
Expand Up @@ -10,7 +10,7 @@
# This needs to be updated each time Habitat is released so we ensure we're getting the version
# required by this cookbook.
describe command('hab -V') do
its('stdout') { should match(%r{^hab 0.79.1/}) }
its('stdout') { should match(%r{^hab 0.81.0/}) }
its('exit_status') { should eq 0 }
end

Expand Down
3 changes: 3 additions & 0 deletions test/integration/license/default_spec.rb
@@ -0,0 +1,3 @@
describe file('/hab/accepted-licenses/habitat') do
it { should exist }
end
2 changes: 1 addition & 1 deletion test/integration/package/default_spec.rb
Expand Up @@ -10,7 +10,7 @@
# This needs to be updated each time Habitat is released so we ensure we're getting the version
# required by this cookbook.
describe command('hab -V') do
its('stdout') { should match(%r{^hab 0.79.1/}) }
its('stdout') { should match(%r{^hab 0.81.0/}) }
its('exit_status') { should eq 0 }
end

Expand Down
2 changes: 1 addition & 1 deletion test/integration/user-toml/default_spec.rb
Expand Up @@ -10,7 +10,7 @@
# This needs to be updated each time Habitat is released so we ensure we're getting the version
# required by this cookbook.
describe command('hab -V') do
its('stdout') { should match(%r{^hab 0.79.1/}) }
its('stdout') { should match(%r{^hab 0.81.0/}) }
its('exit_status') { should eq 0 }
end

Expand Down

0 comments on commit e563ab8

Please sign in to comment.