2
votes

The software I am installing via puppet in Centos7 creates a default folder with some files inside that folder. However, I would like to move that directory to another directory via a symlink. I manage to get it working for one run with the following code:

  #create symlink for xlog partition
  file { '/pglogs/94/':
    ensure  => present,
    source  => "/var/lib/pgsql/9.4/data/pg_xlog/",
    recurse => true,
  } ->
  file { '/var/lib/pgsql/9.4/data/pg_xlog/':
    ensure => 'link',
    target => '/pglogs/94/',
    force  => true,
  }

But from the second run I get errors:

Notice: /Stage[main]/Dap::Dwh/File[/pglogs/94/]: Not removing directory; use 'force' to override Notice: /Stage[main]/Dap::Dwh/File[/pglogs/94/]: Not removing directory; use 'force' to override Error: Could not remove existing file Error: /Stage[main]/Dap::Dwh/File[/pglogs/94/]/ensure: change from directory to link failed: Could not remove existing file Notice: /Stage[main]/Dap::Dwh/File[/pglogs/94/archive_status]: Dependency File[/pglogs/94/] has failures: true Warning: /Stage[main]/Dap::Dwh/File[/pglogs/94/archive_status]: Skipping because of failed dependencies Notice: /Stage[main]/Dap::Dwh/File[/pglogs/94/000000010000000000000001]: Dependency File[/pglogs/94/] has failures: true Warning: /Stage[main]/Dap::Dwh/File[/pglogs/94/000000010000000000000001]: Skipping because of failed dependencies Notice: /Stage[main]/Dap::Dwh/File[/var/lib/pgsql/9.4/data/pg_xlog/]: Dependency File[/pglogs/94/] has failures: true Warning: /Stage[main]/Dap::Dwh/File[/var/lib/pgsql/9.4/data/pg_xlog/]: Skipping because of failed dependencies

It should not try to copy the files again when the symlink is already created. But it seems it still tries..

1

1 Answers

2
votes

ok, I found the answer.

I forgot to add the 'links => follow' the the copy part. The code in the ends becomes something like this:

#create symlink for xlog partition
file { '/pglogs/94/':
  ensure  => present,
  source  => "/var/lib/pgsql/9.4/data/pg_xlog/",
  recurse => true,
  links   => follow,
} ->
file { '/var/lib/pgsql/9.4/data/pg_xlog/':
  ensure => 'link',
  target => '/pglogs/94/',
  force  => true,
}  

The links => follow makes sure the copy statement knows that it are the files are already present.