34 changes: 2 additions & 32 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,33 +232,7 @@ simple tests against it after applying the module. You can run this
with:

```sh
bundle exec rake beaker
```

This will run the tests on the module's default nodeset. You can override the
nodeset used, e.g.,

```sh
BEAKER_set=centos-7-x64 bundle exec rake beaker
```

There are default rake tasks for the various acceptance test modules, e.g.,

```sh
bundle exec rake beaker:centos-7-x64
bundle exec rake beaker:ssh:centos-7-x64
```

If you don't want to have to recreate the virtual machine every time you can
use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at
least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the
created virtual machines will be in `.vagrant/beaker_vagrant_files`.

Beaker also supports docker containers. We also use that in our automated CI
pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant:

```sh
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
BEAKER_setfile=debian10-x64 bundle exec rake beaker
```

You can replace the string `debian10` with any common operating system.
Expand All @@ -272,11 +246,7 @@ The following strings are known to work:
* centos7
* centos8

The easiest way to debug in a docker container is to open a shell:

```sh
docker exec -it -u root ${container_id_or_name} bash
```
For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests).

The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb)
repository.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ jobs:
setup_matrix:
name: 'Setup Test Matrix'
runs-on: ubuntu-latest
timeout-minutes: 40
outputs:
beaker_setfiles: ${{ steps.get-outputs.outputs.beaker_setfiles }}
puppet_major_versions: ${{ steps.get-outputs.outputs.puppet_major_versions }}
puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }}
env:
BUNDLE_WITHOUT: development:test:release
BUNDLE_WITHOUT: development:release
steps:
- uses: actions/checkout@v2
- name: Setup ruby
Expand All @@ -21,13 +22,16 @@ jobs:
bundler-cache: true
- name: Run rake validate
run: bundle exec rake validate
- name: Run rake rubocop
run: bundle exec rake rubocop
- name: Setup Test Matrix
id: get-outputs
run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false

unit:
needs: setup_matrix
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
modulesync_config_version: '4.0.0'
modulesync_config_version: '4.1.0'
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v4.0.0](https://github.com/voxpupuli/puppet-zypprepo/tree/v4.0.0) (2021-04-09)

[Full Changelog](https://github.com/voxpupuli/puppet-zypprepo/compare/v3.1.0...v4.0.0)

**Breaking changes:**

- Drop EoL Puppet 5 support / Add Puppet 7 support [\#62](https://github.com/voxpupuli/puppet-zypprepo/pull/62) ([bastelfreak](https://github.com/bastelfreak))

**Implemented enhancements:**

- puppetlabs/concat and puppetlabs/stdlib: Allow version 7 [\#61](https://github.com/voxpupuli/puppet-zypprepo/pull/61) ([bastelfreak](https://github.com/bastelfreak))

**Fixed bugs:**

- Fix the value declaration of type [\#60](https://github.com/voxpupuli/puppet-zypprepo/pull/60) ([dadav](https://github.com/dadav))

**Closed issues:**

- Repo doesnt actually gets enabled [\#59](https://github.com/voxpupuli/puppet-zypprepo/issues/59)
- Unable to manage path property [\#57](https://github.com/voxpupuli/puppet-zypprepo/issues/57)
- PDK and add tests [\#53](https://github.com/voxpupuli/puppet-zypprepo/issues/53)
- Errors when another zypper is running [\#12](https://github.com/voxpupuli/puppet-zypprepo/issues/12)

**Merged pull requests:**

- Allow changing of path property [\#58](https://github.com/voxpupuli/puppet-zypprepo/pull/58) ([tuxmea](https://github.com/tuxmea))
- Add unit tests for zypprepo type/provider [\#55](https://github.com/voxpupuli/puppet-zypprepo/pull/55) ([tuxmea](https://github.com/tuxmea))

## [v3.1.0](https://github.com/voxpupuli/puppet-zypprepo/tree/v3.1.0) (2020-12-12)

[Full Changelog](https://github.com/voxpupuli/puppet-zypprepo/compare/v3.0.0...v3.1.0)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.5.3
FROM ruby:2.7

WORKDIR /opt/puppet

Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ group :system_tests do
end

group :release do
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes'
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
gem 'github_changelog_generator', '>= 1.16.1', :require => false
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
end

gem 'puppetlabs_spec_helper', '~> 2.0', :require => false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ zypprepo { 'openSUSE_12.1':
autorefresh => 1,
name => 'openSUSE_12.1',
gpgcheck => 1,
repo_gpgcheck => 0,
repo_gpgcheck => 1,
pkg_gpgcheck => 1,
priority => 98,
keeppackages => 1,
Expand Down
29 changes: 12 additions & 17 deletions lib/puppet/provider/zypprepo/inifile.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# Description of zypper repositories
require 'puppet/util/inifile'


Puppet::Type.type(:zypprepo).provide(:inifile) do
desc <<-EOD
Manage zypper repo configurations by parsing zypper INI configuration files.
### Fetching instances
When fetching repo instances, directory entries in '/etc/zypp/repos.d',
and the directory optionally specified by the reposdir key in '/etc/zypp/zypper.conf'
and the directory optionally specified by the reposdir key in '/etc/zypp/zypp.conf'
will be checked. If a given directory does not exist it will be ignored.
In addition, all sections in '/etc/zypp/zypper.conf' aside from
In addition, all sections in '/etc/zypp/zypp.conf' aside from
'main' will be created as sections.
### Storing instances
When creating a new repository, a new section will be added in the first
zypper repo directory that exists. The custom directory specified by the
'/etc/zypp/zypper.conf' reposdir property is checked first, followed by
'/etc/zypp/zypp.conf' reposdir property is checked first, followed by
'/etc/zypp/repos.d'.
EOD

Expand All @@ -31,7 +30,7 @@ def self.instances
instances = []

virtual_inifile.each_section do |section|
# Ignore the 'main' section in zypper.conf since it's not a repository.
# Ignore the 'main' section in zypp.conf since it's not a repository.
next if section.name == 'main'

attributes_hash = { name: section.name, ensure: :present, provider: :zypprepo }
Expand Down Expand Up @@ -59,23 +58,21 @@ def self.prefetch(resources)
repos = instances
resources.each_key do |name|
provider = repos.find { |repo| repo.name == name }
if provider
resources[name].provider = provider
end
resources[name].provider = provider if provider
end
end


#
# @api private
# @param conf [String] Configuration file to look for directories in.
# @param dirs [Array<String>] Default locations for zypper repos.
# @return [Array<String>] All present directories that may contain zypper repo configs.
def self.reposdir(conf = '/etc/zypp/zypper.conf', dirs = ['/etc/zypp/repos.d'])
def self.reposdir(conf = '/etc/zypp/zypp.conf', dirs = ['/etc/zypp/repos.d'])
reposdir = find_conf_value('reposdir', conf)
# Use directories in reposdir if they are set instead of default
if reposdir
# Follow the code from the yumrepo provider
reposdir.strip!
reposdir.tr!("\n", ' ')
reposdir.tr!(',', ' ')
dirs = reposdir.split
Expand All @@ -100,7 +97,7 @@ def self.clear
# @param value [String] Value to look for in the configuration file.
# @param conf [String] Configuration file to check for value.
# @return [String] The value of a looked up key from the configuration file.
def self.find_conf_value(value, conf = '/etc/zypp/zypper.conf')
def self.find_conf_value(value, conf = '/etc/zypp/zypp.conf')
return unless Puppet::FileSystem.exist?(conf)

file = Puppet::Util::IniConfig::PhysicalFile.new(conf)
Expand All @@ -112,7 +109,7 @@ def self.find_conf_value(value, conf = '/etc/zypp/zypper.conf')
# Enumerate all files that may contain zypper repository configs.
#
# @api private
# @return [Array<String>
# @return [Array<String>]
def self.repofiles
files = []
reposdir.each do |dir|
Expand Down Expand Up @@ -179,8 +176,7 @@ def self.store(resource)
next unless Puppet::FileSystem.exist?(file)
current_mode = Puppet::FileSystem.stat(file).mode & 0o777
next if current_mode == target_mode
resource.info _('changing mode of %{file} from %{current_mode} to %{target_mode}') %
{ file: file, current_mode: '%03o' % current_mode, target_mode: '%03o' % target_mode }
resource.info format(_('changing mode of %{file} from %{current_mode} to %{target_mode}'), file: file, current_mode: format('%03o', current_mode), target_mode: format('%03o', target_mode))
Puppet::FileSystem.chmod(target_mode, file)
end
end
Expand Down Expand Up @@ -279,7 +275,7 @@ def descr
end

def descr=(value)
value = ((value == :absent) ? nil : value)
value = (value == :absent ? nil : value)
current_section['name'] = value
@property_hash[:descr] = value
end
Expand All @@ -295,7 +291,7 @@ def get_property(property)
end

def set_property(property, value)
value = ((value == :absent) ? nil : value)
value = (value == :absent ? nil : value)
current_section[property.to_s] = value
@property_hash[property] = value
end
Expand All @@ -307,5 +303,4 @@ def section(name)
def current_section
self.class.section(name)
end

end
Loading