Skip to content

Commit

Permalink
Allow changing action behaviour of the package resource (#372)
Browse files Browse the repository at this point in the history
* Allow changing action behaviour of the package resource

* Update CHANGELOG.md for #372
  • Loading branch information
fspijkerman committed Aug 30, 2023
1 parent 9a9b4eb commit ff2866d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Allow changing action behaviour of the package resource (:install, :upgrade)

## 5.4.0 - *2023-08-19*

- Treat redhat like other members of the platform_family when generating yum repo url
Expand Down
3 changes: 2 additions & 1 deletion documentation/resource_mariadb_client_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ This resource installs mariadb client packages.

Name | Types | Description | Default | Required?
------------------- | ----------------- | ------------------------------------------------------------- | ----------------------------------------- | ---------
`version` | String | Version of MariaDB to install | `10.3` | no
`version` | String | Version of MariaDB to install | `10.11` | no
`setup_repo` | Boolean | Define if you want to add the MariaDB repository | `true` | no
`package_action` | :install, :upgrade| Package action behaviour | `:install` | no

### Examples

Expand Down
3 changes: 2 additions & 1 deletion documentation/resource_mariadb_server_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ This resource installs mariadb server packages.

Name | Types | Description | Default | Required?
------------------------------- | ----------------- | ------------------------------------------------------------- | ----------------------------------------- | ---------
`version` | String | Version of MariaDB to install | `10.3` | no
`version` | String | Version of MariaDB to install | `10.11` | no
`setup_repo` | Boolean | Define if you want to add the MariaDB repository | `true` | no
`password` | String, nil | Pass in a password, or have the cookbook generate one for you | `generate` | no
`install_sleep` | Integer | Number of seconds to sleep in between install commands | `5` | no
`package_action` | :install, :upgrade| Package action behaviour | `:install` | no

(1) `default_pid_file` is a helper method which return the pid file name and path based on OS flavor

Expand Down
9 changes: 6 additions & 3 deletions resources/client_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
provides :mariadb_client_install
unified_mode true

property :version, String, default: '10.11'
property :setup_repo, [true, false], default: true
property :version, String, default: '10.11'
property :setup_repo, [true, false], default: true
property :package_action, [:install, :upgrade], default: :install

action :install do
mariadb_repository 'Add mariadb.org repository' do
version new_resource.version
only_if { new_resource.setup_repo }
end

package client_pkg_name
package client_pkg_name do
action new_resource.package_action
end
end

action_class do
Expand Down
14 changes: 9 additions & 5 deletions resources/server_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@

include MariaDBCookbook::Helpers

property :version, String, default: '10.11'
property :setup_repo, [true, false], default: true
property :password, [String, nil], default: 'generate'
property :install_sleep, Integer, default: 5, desired_state: false
property :version, String, default: '10.11'
property :setup_repo, [true, false], default: true
property :password, [String, nil], default: 'generate'
property :install_sleep, Integer, default: 5, desired_state: false
property :package_action, [:install, :upgrade], default: :install

action :install do
mariadb_client_install 'Install MariaDB Client' do
version new_resource.version
setup_repo new_resource.setup_repo
package_action new_resource.package_action
end

package server_pkg_name
package server_pkg_name do
action new_resource.package_action
end

selinux_install 'mariadb' if selinux_enabled?

Expand Down

0 comments on commit ff2866d

Please sign in to comment.