Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

Make variables subscriptable #6

Description

@puetzp

Since StrictYAML parses all literals as strings, variables fit into configuration files seamlessly without having to quote them:

number: 400
line: some string
variable: ${pullconf::some-variable}

Right now variables need to resolve to the same type that is expected from the parameter where the variable is found or resolve to a string if substring substitution is used inside another string parameter:

variables:
  ip: 192.168.0.200
  mode: 0600

resources:
  - type: host
    parameters:
      ip_address: ${pullconf::ip}
      hostname: ${pullconf::hostname}
      aliases:
        - me
        - myself
        - I
  - type: file
    parameters:
      path: /etc/ssh/sshd_config
      content: |
        ...
        Listen ${pullconf::ip}
        ...

It would be useful if variables were subscriptable in a way so values inside hash and array variables can be accessed:

variables:
  sshd:
    port: 22
    ip: 192.168.0.200

  - type: file
    parameters:
      path: /etc/ssh/sshd_config
      mode: ${pullconf::mode}
      content: |
        ...
        Listen ${pullconf::sshd.ip}
        Port ${pullconf::sshd.port}
        ...

The syntax for accessing values inside hashes and arrays could be:

  • dots for accessing keys inside hashes
  • numbers inside square brackets to access array elements

Making variables subscriptable allows users to organize their variables better.

Possible issues: Variables should still be able to contain other variables. Resolving variables thus becomes a little more complex.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions