Ansible: set facts using conditionals

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024
  • Ansible - Set_facts contional example
    Checkout all the code on my gist: gist.github.co...
    In ansible, like any other programming language, at some point, we’ll want to set a variable for something. This is fairly simple to do when it’s just one value, but if we need to pick that value from the server we run ansible against, it gets a bit trickier.
    For example:
    I’m running my playbook/role against a list of servers. I need to be able to identify which DC each server is in so I can apply the correct nameservers, timeservers, nfs mounts points, and anything else. I want my code to run on all the servers, set the fact based on something unique to that server, and then apply the configuration.
    In this video I’ll show you the following:
    • How to generate static facts
    • How to use a conditional statement to set a fact
    • How to combine the facts into a string

Комментарии • 13

  • @cliffcampbell83
    @cliffcampbell83 Месяц назад

    Great concise explanation. Thanks

  • @asaac7
    @asaac7 2 года назад +2

    Nice explanation

    • @LondonIAC
      @LondonIAC  2 года назад +1

      thanks, I'm glad it was helpful!

  • @rajneeshDBA
    @rajneeshDBA 2 года назад

    Why assert conditions are not printing anything

    • @LondonIAC
      @LondonIAC  2 года назад

      Hi Raj, I don't use "assert" in this demo. Do you mean one of my other videos?

  • @kenhitchcock4075
    @kenhitchcock4075 2 года назад +1

    Good stuff Dennis, good explanation.

  • @piyush42962
    @piyush42962 2 года назад +1

    Very nice video. Thanks

    • @LondonIAC
      @LondonIAC  2 года назад

      Thanks. I'm glad you like it and I hope it was useful.

  • @tommymogensen8456
    @tommymogensen8456 2 года назад +1

    Very useful - thank you.

    • @LondonIAC
      @LondonIAC  2 года назад

      Glad it was helpful!

  • @RABWA333
    @RABWA333 2 года назад

    Nice video, thanks