Skip to content

Instantly share code, notes, and snippets.

@hatifnatt
Created July 11, 2017 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatifnatt/fb9afa4f5c79441e0616d03147b18a03 to your computer and use it in GitHub Desktop.
Save hatifnatt/fb9afa4f5c79441e0616d03147b18a03 to your computer and use it in GitHub Desktop.
Error with SaltStack network.get_hostname when invoked from Jinja

State file

{%- set myhost = salt['network.get_hostname'] %}
test_state:
  test.configurable_test_state:
    - name: test_state
    - comment: {{ myhost }}

Output

# salt 'vds01*' state.sls gethostname test=True --out=yaml
vds01:
  test_|-test_state_|-test_state_|-configurable_test_state:
    __id__: test_state
    __run_num__: 0
    changes:
      testing:
        new: Something pretended to change
        old: Unchanged
    comment: <function get_hostname at 0x3d7fb18>
    duration: 0.324
    name: test_state
    result: null
    start_time: '18:57:07.849192'

When executed from cli it's all right

# salt 'vds01*' network.get_hostname
vds01:
    vds01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment