Skip to content

Commit

Permalink
Fixes and production testing :
Browse files Browse the repository at this point in the history
- Change config dir location
- Fix Service file
- Fix command authorization request
  • Loading branch information
syberalexis committed Apr 11, 2020
1 parent 6525ab0 commit 81bfb28
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 62 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to this project will be documented in this file.

## Release 0.1.3

**Bug fixes**

- Change config dir location
- Fix Service file
- Fix command authorization request

## Release 0.1.2

**Bug fixes**

- Fix Unzip package forgot

## Release 0.1.1

**Bug fixes**
Expand Down
52 changes: 22 additions & 30 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Data type: `Stdlib::HTTPUrl`

Base URL for storj.

Default value: 'https://github.com/storj/storj/releases'
Default value: 'https://github.com/storj/storj/releases/download'

##### `download_extension`

Expand All @@ -132,6 +132,14 @@ Custom command passed to the archive resource to extract the downloaded archive.

Default value: `undef`

##### `config_dir`

Data type: `Stdlib::Absolutepath`

Directory where configuration are located.

Default value: "/etc/storj"

##### `manage_user`

Data type: `Boolean`
Expand Down Expand Up @@ -164,14 +172,6 @@ Group under which storj is running.

Default value: 'storj'

##### `home`

Data type: `String`

User's home running storj.

Default value: '/home/storj'

##### `usershell`

Data type: `Stdlib::Absolutepath`
Expand All @@ -188,14 +188,6 @@ Add other groups to the managed user.

Default value: []

##### `identity_dir`

Data type: `Stdlib::Absolutepath`

Storj identity node directory. See https://documentation.storj.io/dependencies/identity

Default value: "${home}/.local/share/storj/identity"

##### `service_ensure`

Data type: `Variant[Stdlib::Ensure::Service, Enum['absent']]`
Expand Down Expand Up @@ -270,13 +262,13 @@ Directory where binaries are located.

Default value: $storj::bin_dir

##### `identity_dir`
##### `config_dir`

Data type: `Stdlib::Absolutepath`

Storj identity node directory. See https://documentation.storj.io/dependencies/identity
Directory where configuration are located.

Default value: $storj::identity_dir
Default value: $storj::config_dir

##### `user`

Expand Down Expand Up @@ -374,6 +366,14 @@ Custom command passed to the archive resource to extract the downloaded archive.

Default value: $storj::extract_command

##### `config_dir`

Data type: `Stdlib::Absolutepath`

Directory where configuration are located.

Default value: $storj::config_dir

##### `manage_user`

Data type: `Boolean`
Expand Down Expand Up @@ -406,14 +406,6 @@ Group under which storj is running.

Default value: $storj::group

##### `home`

Data type: `String`

User's home running storj.

Default value: $storj::home

##### `usershell`

Data type: `Stdlib::Absolutepath`
Expand Down Expand Up @@ -518,13 +510,13 @@ Amount of dedicated storage.

Default value: $storj::storage

##### `identity_dir`
##### `config_dir`

Data type: `Stdlib::Absolutepath`

Storj identity node directory. See https://documentation.storj.io/dependencies/identity

Default value: $storj::identity_dir
Default value: $storj::config_dir

##### `storage_path`

Expand Down
14 changes: 7 additions & 7 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Received personal single-use authorization token. See https://documentation.storj.io/before-you-begin/auth-token
# @param bin_dir
# Directory where binaries are located.
# @param identity_dir
# Storj identity node directory. See https://documentation.storj.io/dependencies/identity
# @param config_dir
# Directory where configuration are located.
# @param user
# User running storj.
# @param group
Expand All @@ -15,21 +15,21 @@
class storj::config (
Storj::Authorization_token $authorization_token = $storj::authorization_token,
Stdlib::Absolutepath $bin_dir = $storj::bin_dir,
Stdlib::Absolutepath $identity_dir = $storj::identity_dir,
Stdlib::Absolutepath $config_dir = $storj::config_dir,
String $user = $storj::user,
String $group = $storj::group,
) {
exec { 'Request authorization command':
command => "${bin_dir}/idetntity authorize storagenode ${authorization_token} --identity-dir ${identity_dir}",
creates => "${identity_dir}/storagenode/identity.cert",
command => "${bin_dir}/identity authorize storagenode ${authorization_token} --identity-dir ${config_dir} --config-dir ${config_dir}",
onlyif => "/usr/bin/test `grep -c BEGIN ${config_dir}/storagenode/identity.cert` != 3",
user => $group,
group => $user,
logoutput => true,
notify => Service['storagenode'],
}
-> exec { 'Check certs integrity command':
command => "/usr/bin/test `grep -c BEGIN ${identity_dir}/storagenode/ca.cert` == 2 &&
/usr/bin/test `grep -c BEGIN ${identity_dir}/storagenode/identity.cert` == 3",
command => "/usr/bin/test `grep -c BEGIN ${config_dir}/storagenode/ca.cert` == 2 &&
/usr/bin/test `grep -c BEGIN ${config_dir}/storagenode/identity.cert` == 3",
logoutput => true,
returns => 0,
}
Expand Down
11 changes: 3 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
# Complete URL corresponding to the Storj release, default to undef.
# @param extract_command
# Custom command passed to the archive resource to extract the downloaded archive.
# @param config_dir
# Directory where configuration are located.
# @param manage_user
# Whether to create user for storj or rely on external code for that.
# @param manage_group
Expand All @@ -38,14 +40,10 @@
# User running storj.
# @param group
# Group under which storj is running.
# @param home
# User's home running storj.
# @param usershell
# if requested, we create a user for storj. The default shell is false. It can be overwritten to any valid path.
# @param extra_groups
# Add other groups to the managed user.
# @param identity_dir
# Storj identity node directory. See https://documentation.storj.io/dependencies/identity
# @param service_ensure
# State ensured from storagenode service.
# @param docker_tag
Expand Down Expand Up @@ -77,19 +75,16 @@
String $download_extension = 'zip',
Optional[Stdlib::HTTPUrl] $download_url = undef,
Optional[String] $extract_command = undef,
Stdlib::Absolutepath $config_dir = "/etc/storj",

# User Management
Boolean $manage_user = true,
Boolean $manage_group = true,
String $user = 'storj',
String $group = 'storj',
String $home = '/home/storj',
Stdlib::Absolutepath $usershell = '/bin/false',
Array[String] $extra_groups = [],

# Configuration
Stdlib::Absolutepath $identity_dir = "${home}/.local/share/storj/identity",

# Service
Variant[Stdlib::Ensure::Service, Enum['absent']] $service_ensure = 'running',
String $docker_tag = 'beta',
Expand Down
23 changes: 11 additions & 12 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# Complete URL corresponding to the Storj release, default to undef.
# @param extract_command
# Custom command passed to the archive resource to extract the downloaded archive.
# @param config_dir
# Directory where configuration are located.
# @param manage_user
# Whether to create user for storj or rely on external code for that.
# @param manage_group
Expand All @@ -24,8 +26,6 @@
# User running storj.
# @param group
# Group under which storj is running.
# @param home
# User's home running storj.
# @param usershell
# if requested, we create a user for storj. The default shell is false. It can be overwritten to any valid path.
# @param extra_groups
Expand All @@ -41,13 +41,13 @@
String $download_extension = $storj::download_extension,
Stdlib::HTTPUrl $download_url = $storj::real_download_url,
Optional[String] $extract_command = $storj::extract_command,
Stdlib::Absolutepath $config_dir = $storj::config_dir,

# User Management
Boolean $manage_user = $storj::manage_user,
Boolean $manage_group = $storj::manage_group,
String $user = $storj::user,
String $group = $storj::group,
String $home = $storj::home,
Stdlib::Absolutepath $usershell = $storj::usershell,
Array[String] $extra_groups = $storj::extra_groups,
) {
Expand Down Expand Up @@ -84,27 +84,26 @@
ensure_resource('user', [ $user ], {
ensure => 'present',
system => true,
home => $home,
groups => concat([$group, 'docker'], $extra_groups),
shell => $usershell,
})

file { $home:
ensure => 'directory',
owner => $user,
group => $group,
}

User[$user] -> File[$home]
User[$user] -> File[$config_dir]

if $manage_group {
Group[$group] -> User[$user]
}
}
if $manage_group {
ensure_resource('group', [ $group ],{
ensure_resource('group', [ $group ], {
ensure => 'present',
system => true,
})
}

file { $config_dir:
ensure => 'directory',
owner => $user,
group => $group,
}
}
4 changes: 2 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Your node hostname / DNS altname (required to be accessible). See https://documentation.storj.io/dependencies/port-forwarding
# @param storage
# Amount of dedicated storage.
# @param identity_dir
# @param config_dir
# Storj identity node directory. See https://documentation.storj.io/dependencies/identity
# @param storage_path
# Mounted device location.
Expand All @@ -37,7 +37,7 @@
String $mail = $storj::mail,
Stdlib::Host $host = $storj::host,
String $storage = $storj::storage,
Stdlib::Absolutepath $identity_dir = $storj::identity_dir,
Stdlib::Absolutepath $config_dir = $storj::config_dir,
Stdlib::Absolutepath $storage_path = $storj::storage_path,
String $docker_tag = $storj::docker_tag,
) {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maeq-storj",
"version": "0.1.1",
"version": "0.1.3",
"author": "maeq",
"summary": "This module install and configure Storj storagenode",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions templates/service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ ExecStart=/usr/bin/docker run --name ${NAME} \
-p <%= @dashboard_port %>:14002 \
-e WALLET="<%= @wallet %>" \
-e EMAIL="<%= @mail %>" \
-e ADDRESS="<%= @host %>" \
-e ADDRESS="<%= @host %>:<%= @port %>" \
-e STORAGE="<%= @storage %>" \
--mount type=bind,source="<%= @identity_dir %>/storagenode",destination=/app/identity \
--mount type=bind,source="<%= @config_dir %>/storagenode",destination=/app/identity \
--mount type=bind,source="<%= @storage_path %>",destination=/app/config \
storjlabs/storagenode:<%= @docker_tag %>
ExecStop=/usr/bin/docker stop ${NAME}
Expand Down

0 comments on commit 81bfb28

Please sign in to comment.