Ansible conditionals using When & Register

Опубликовано: 13 Май 2021
на канале: LondonIAC / Dennis McCarthy / Automation Engineer
2,869
39

I'll show you how to use some basic but powerful conditional statements to control when a task runs in this demo.

This is what's covered:

• I’ll be using 2 servers today. 1 centos 8 and one ubuntu 20.04
• I’ll use the fact: "ansible_os_family" to only create a file on a Debian based server
• Next we’ll run a command to get the AWS Instance type of each node.
• If the server is a T2.small, we’ll create a file, otherwise, ignore it.
• To do this we’ll use "register" to collect the output of the command
• Then use “when:” to only run the task if it’s a T2.small.
• Finally we’ll reverse the conditional

Once you understand conditionals, adapt my examples on your own code and see how much of a difference it gives you.

As always, Subscribe for more videos like this and please message me in the comments if you'd like me to make a demo on something you'd like to see.


Смотрите видео Ansible conditionals using When & Register онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь LondonIAC / Dennis McCarthy / Automation Engineer 13 Май 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,869 раз и оно понравилось 39 людям.