ffrank / puppet-mgmtgraph

The mgmt translator for Puppet manifests
Other
11 stars 4 forks source link

File source is handled wrongly #24

Open ffrank opened 4 years ago

ffrank commented 4 years ago

File resources that manage directories have good handling for the source property, e.g. when it's a puppet:// URL:

puppet mgmtgraph print --code 'file { "/path/to/managed/dir": ensure => "directory", source => "puppet:///modules
/local_files/my_managed_dir" }'
...
Error: File[/path/to/managed/dir] uses a puppet fileserver URL source - this will not be translated
Warning: File[/path/to/managed/dir] emitting a `exec puppet resource` node because of the errors above.
Error: File[/path/to/managed/dir] cannot be translated natively, falling back to pippet
...
resources:
  pippet:
  - name: File[/path/to/managed/dir]
    title: "/path/to/managed/dir"
    type: file
    params: |-
      {"path": "/path/to/managed/dir", "provider": "posix", "ensure": "directory", "source": [
          "puppet:///modules/local_files/my_managed_dir"], "backup": "puppet", "replace": true,
        "links": "manage", "purge": false, "sourceselect": "first", "show_diff": true, "validate_replacement": "%",
        "checksum": "md5", "source_permissions": "ignore", "selinux_ignore_defaults": "false",
        "loglevel": "notice"}
    pollint: 1800

This is not quite the case for flat files.

puppet mgmtgraph print --code 'file { "/path/to/managed/file": source => "puppet:///modules/local_files/my_managed
_file" }'
...
resources:
  file:
  - name: "/path/to/managed/file"
    path: "/path/to/managed/file"

Make sure that source is always handled correctly.