puppet copy directory but not its content

user2478159

I want to manage files /home/user_name/scripts/file0, /home/user_name/scripts/file1, ... on my nodes, as copies of files with the same paths on the master.

Relying on /home/user_name to be present on every node, I put this in the manifest:

file { '/home/user_name/scripts':
  ensure  => 'directory',
  path    => '/home/user_name/scripts',
  recurse => true
}

That indeed gets the directory created on each of the nodes, but the contents file0, file1, ... are not copied.

I tried to add a source parameter, and also recurse=>remote, but with no further success.

Update: Trying to add the source parameter, I added:

file { '/home/user_name/scripts':
  ensure  => 'directory',
  path    => '/home/user_name/scripts',
  recurse => true,
  source  => '/home/user_name/scripts'
}

But with no success. Btw, here's the output when running puppet apply

Notice: Compiled catalog for puppet, master_dns in environment production in 0.64 seconds
Notice: /Stage[main]/Exec_script/Exec[add_archi]/returns: executed successfully
Notice: Applied catalog in 2.60 seconds
John Bollinger

@MattSchuchard already pointed you to the relevant documentation. They explain that Puppet supports four alternatives for the form of the source parameter, and that the form you're trying to use relies on local files as the source of the files being managed. That is, local to the node being configured.

If you want to use files residing on the master as the source, and they are not directly accessible to clients (e.g. via a network file system), then you have only two alternatives left: a URI using either the puppet: or the http: scheme. Unless you want to run an HTTP server on your master, only a puppet: URI is really a viable option.

By default, however, Puppet's file server serves files only out of modules, not from arbitrary paths. And why would you want to serve arbitrary files from the master's file system? What a recipe for disaster. And why would general users need home directories on the master anyway?

The best solution would be to put the directory tree in whatever module your file resource appears in -- say at mymodule/files/user_name/scripts. Then you could write your resource like so:

file { '/home/user_name/scripts':
  ensure  => 'directory',
  recurse => true,
  source  => 'puppet://modules/mymodule/user_name/scripts'
}

But if you insist, you should be able to leave the source files where they are now, and patch it together with a symlink:

mymodule/files/user_name-scripts -> /home/user_name/scripts

... and ...

file { '/home/user_name/scripts':
  ensure  => 'directory',
  recurse => true,
  source  => 'puppet://modules/mymodule/user_name-scripts',
  links   => 'follow'
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Copy recursively a directory excluding a subdirectory and ITS CONTENT

From Dev

Robocopy copy directory instead of just its content

From Dev

Copy directory content

From Dev

Copy node and alter its content

From Java

Get the size of a directory (not its content)

From Dev

Ansible: copy a directory content to another directory

From Dev

How to find a file and copy its directory?

From Dev

How to copy formula without changing its content?

From Dev

Lock or unlock a directory and its content recursively

From Dev

How to remove a directory without removing its content?

From Dev

Add specific directory and its content to Universal target

From Dev

delete directory object and its content in powershell

From Dev

How to remove a directory without removing its content?

From Dev

archive a directory and its content to a zip archive

From Dev

Add specific directory and its content to Universal target

From Dev

how to copy a directory (folder and its contents) to another directory?

From Dev

Copy htm and its supported files and directory to other directory using CMD

From Dev

Redirecting the content of a directory, but not the directory itself as well as some of its subdirectories and files

From Dev

Copy content of one directory in bare repo to directory outside repo

From Dev

How to copy a file within its original directory, most easily?

From Dev

Grunt.js: copy file without its parent directory

From Dev

How can I copy a hidden directory recursively and preserving its permissions?

From Dev

How do I copy the directory and its folders in windows command line?

From Dev

Make innosetup copy the full folder instead of only its content

From Dev

Get size of directory (including all its content) irrespective of disk usage

From Dev

Python - How to copy content of USB(Flash) to system directory

From Dev

Copy the content/file to all subdirectory in a directory using terminal

From Dev

Error when trying to copy directory content with rsync inside a shell script

From Dev

Python - How to copy content of USB(Flash) to system directory

Related Related

  1. 1

    Copy recursively a directory excluding a subdirectory and ITS CONTENT

  2. 2

    Robocopy copy directory instead of just its content

  3. 3

    Copy directory content

  4. 4

    Copy node and alter its content

  5. 5

    Get the size of a directory (not its content)

  6. 6

    Ansible: copy a directory content to another directory

  7. 7

    How to find a file and copy its directory?

  8. 8

    How to copy formula without changing its content?

  9. 9

    Lock or unlock a directory and its content recursively

  10. 10

    How to remove a directory without removing its content?

  11. 11

    Add specific directory and its content to Universal target

  12. 12

    delete directory object and its content in powershell

  13. 13

    How to remove a directory without removing its content?

  14. 14

    archive a directory and its content to a zip archive

  15. 15

    Add specific directory and its content to Universal target

  16. 16

    how to copy a directory (folder and its contents) to another directory?

  17. 17

    Copy htm and its supported files and directory to other directory using CMD

  18. 18

    Redirecting the content of a directory, but not the directory itself as well as some of its subdirectories and files

  19. 19

    Copy content of one directory in bare repo to directory outside repo

  20. 20

    How to copy a file within its original directory, most easily?

  21. 21

    Grunt.js: copy file without its parent directory

  22. 22

    How can I copy a hidden directory recursively and preserving its permissions?

  23. 23

    How do I copy the directory and its folders in windows command line?

  24. 24

    Make innosetup copy the full folder instead of only its content

  25. 25

    Get size of directory (including all its content) irrespective of disk usage

  26. 26

    Python - How to copy content of USB(Flash) to system directory

  27. 27

    Copy the content/file to all subdirectory in a directory using terminal

  28. 28

    Error when trying to copy directory content with rsync inside a shell script

  29. 29

    Python - How to copy content of USB(Flash) to system directory

HotTag

Archive