1

The documentation for the source attribute for the file resource type says:

The available URI schemes are puppet and file. puppet URIs will ...

It then explains the puppet URI scheme, but doesn't say anything about the file URI scheme. What is it? What does it mean to assign "file://foo/bar/baz" to the source attribute on a file resource?

jameshfisher
  • 34,029
  • 31
  • 121
  • 167
  • https://en.wikipedia.org/wiki/File_URI_scheme – Boann Nov 11 '14 at 11:17
  • @Boann okay, but how is it being interpreted by Puppet? For instance, how are relative paths resolved? And what filesystem does it refer to? – jameshfisher Nov 11 '14 at 11:25
  • @Boann for instance, if I reference `"file://foo/bar"` in the file `default.pp`, where there is a file `foo/bar` relative to my `default.pp`, I expect Puppet to find that file, but it doesn't. – jameshfisher Nov 11 '14 at 11:33
  • ‎@jameshfisher I don't know anything about puppet, but file URIs are always absolute by definition. You might try `file:///./foo/bar`, but it's not strictly valid. – Boann Nov 11 '14 at 11:51

1 Answers1

2

The file path is always absolute. It refers to a file on the system that runs the catalog. This is the agent system, or a machine on which you invoke puppet apply.

file {
    '/etc/motd':
        source => "file:///media/shared-storage0/motd/${fqdn}.motd";
}

For example, the above resource will make the agent sync motd contents and file metadata from a shared storage.

You can omit the file:// and just use the full path as the source.

source => "/media/shared-storage0/motd/${fqdn}.motd";
Felix Frank
  • 8,125
  • 1
  • 23
  • 30