Uploaded image for project: 'IGB'
  1. IGB
  2. IGBF-2336

Answer: Can we refer to other variables in a vars_file ?

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      A quick question:

      In a "vars" file in ansible, can you refer to another variable defined in the same file?

      For example, can you do the following?

      var1: hello
      var2: world
      var3: "{{ var1 }} var2"

      That is, what I would like to do is define a variable and then use it to define additional variables elsewhere in a variables file.

      For example, I would like to be able to define "ec2_name" and then re-use it to define the name of the appstore database:

      ec2_name: appstore123
      ...
      rds_db_name: "{{ ec2_name }}"

      Do you know: Is this legal in ansible?

      Asking because you might know the answer off-hand. I have not had much luck searching google for the answer.

      If you don't know it off-hand, just add that as a comment in the ticket. No need to do a lot of deep dive research.

        Attachments

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              cdias1 Chester Dias (Inactive)
              Reporter:
              ann.loraine Ann Loraine
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: