Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file.managed error: is not an absolute path #126

Closed
martinohansen opened this issue May 25, 2019 · 3 comments
Closed

file.managed error: is not an absolute path #126

martinohansen opened this issue May 25, 2019 · 3 comments

Comments

@martinohansen
Copy link

Hi,

Im trying to make a new formula based on this template as it seems like a great starting point. Please be aware; this is one of my first formulas and i might be prone to beginner mistakes.

Running this state:

exabgp-config-file-file-managed:
  file.managed:
    - names:
      - {{ exabgp.config.path }}/{{ exabgp.config.name }}:
        - source: {{ files_switch(['exabgp.conf.jinja']) }}
      - {{ exabgp.env.path }}/{{ exabgp.env.name }}:
        - source: {{ files_switch(['exabgp.env.jinja']) }}
    - mode: 644
    - user: {{ exabgp.user }}
    - group: {{ exabgp.group }}
    - template: jinja
    - require:
      - sls: {{ sls_package_install }}

with defaults.yaml:

exabgp:
  user: nobody
  group: nobody
  config: 
    path: '/etc/exabgp'
    name: 'exabgp.conf'
  env:
    path: '/etc/exabgp'
    name: 'exabgp.env'

Gives me errors like this (with different paths) at the minion:

----------
          ID: exabgp-config-file-file-managed
    Function: file.managed
        Name: salt://exabgp/files/default/exabgp.env.jinja
      Result: False
     Comment: Specified file salt://exabgp/files/default/exabgp.env.jinja is not an absolute path
     Started: 09:11:22.911320
    Duration: 1.762 ms
     Changes:
----------

Let me know if i need to provide more data or a better explanation.

Thanks,
Martin

@myii
Copy link
Member

myii commented May 25, 2019

@martinohansen So, continuing from my message in Slack:

Interesting, this is the first time I've seen TOFS being used with names. By default, the TOFS macro supplies the source with an indent width of 6. In this case, you'll need an indent width of 10. I'll provide a specific example on the issue itself.

Try this instead:

   file.managed:
     - names:
       - {{ exabgp.config.path }}/{{ exabgp.config.name }}:
-        - source: {{ files_switch(['exabgp.conf.jinja']) }}
+        - source: {{ files_switch(['exabgp.conf.jinja'], indent_width=10) }}
       - {{ exabgp.env.path }}/{{ exabgp.env.name }}:
-        - source: {{ files_switch(['exabgp.env.jinja']) }}
+        - source: {{ files_switch(['exabgp.env.jinja'], indent_width=10) }}
     - mode: 644
     - user: {{ exabgp.user }}
     - group: {{ exabgp.group }}

By the way, it's also good practice to provide a lookup as well, so that the template name can be set in the pillar/config as well.

@martinohansen
Copy link
Author

Ah, of course. Thank you so much!

@myii
Copy link
Member

myii commented May 26, 2019

You're welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants