Skip to content

git: when revision is set, owner/group ownership is enforced even in noop mode #579

@bugfood

Description

@bugfood

Describe the Bug

For a vcsrepo resource that has the revision parameter and the owner and/or group parameters set, vcsrepo will change the ownership of an existing directory even when the --noop option is set.

Expected Behavior

A noop run should make no changes to the target system.

Steps to Reproduce

This is an example for the group parameter; the owner parameter behaves the same way.

  1. Create a test.pp file with contents:
vcsrepo { '/tmp/repo':
    ensure   => 'present',
    user     => 'root',
    group    => 'root',
    provider => 'git',
    source   => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git',
    revision => 'main',
}
  1. Apply the file; example output:
$ sudo puppet apply test.pp
Notice: Compiled catalog for <redacted> in environment production in 0.11 seconds
Notice: /Stage[main]/Main/Vcsrepo[/tmp/repo]/ensure: created
Notice: Applied catalog in 0.83 seconds
  1. Check ownership of the new repo directory. Change ownership and check again to ensure the change was made; example output:
$ ls -ld /tmp/repo
drwxr-xr-x 10 root root 4096 Dec  8 22:58 /tmp/repo
$ sudo chown -R :nobody /tmp/repo
$ ls -ld /tmp/repo
drwxr-xr-x 10 root nobody 4096 Dec  8 22:58 /tmp/repo
  1. Do a noop run. Example output:
$ sudo puppet apply test.pp --noop
Notice: Compiled catalog for <redacted> in environment production in 0.10 seconds
Notice: Applied catalog in 0.72 seconds
  1. Check the ownership again, which should be unchanged (still nobody as the group).
$ ls -ld /tmp/repo
drwxr-xr-x 10 root root 4096 Dec  8 22:58 /tmp/repo

Environment

  • Vcsrepo current main: 3d78c5b129e4758a12df7e36a009bdc305509dbd
  • AlmaLinux 8.7
  • Puppet 7.14.0

Additional Context

  • Removing the revision parameter makes this problem go away.
  • The ownership change is recursive--not just to the top-level directory.

Thanks,
Corey

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions