Ansible when conditional explained - Part 9
▬▬▬▬▬▬ ? Courses ▬▬▬▬▬▬
1. Terraform - https://youtu.be/OHzZ7KuioMA
2. Ansible - https://www.youtube.com/watch?v=2hVSpENzhwA&list=PL7iMyoQPMtAPZl58ovoOlxFxNPioSx838
3. Prometheus & Grafana - https://www.youtube.com/watch?v=peH95b16hNI&list=PL7iMyoQPMtAPbN3A7Prac8vfikIPa02wd
4. Helm Chart - https://youtu.be/DQk8HOVlumI
5. Hashi Corp vault - https://www.youtube.com/watch?v=-sU0O82fdZs&list=PL7iMyoQPMtAP7XeXabzWnNKGkCex1C_3C
▬▬▬▬▬▬ ⭐️ Guide and Repository ⭐️ ▬▬▬▬▬▬
Github Repository : https://github.com/rahulwagh/ansible-examples.git
The usage of conditionals, which are used to regulate the playbook's flow based on the values of variables or facts, is one of Ansible's key features. We'll talk about Ansible conditionals and how to utilize them in playbooks in this blog article.
Similar to conditional statements in programming languages, Ansible uses conditionals. They enable us to declare one set of activities to be carried out in the event of a true condition, and a another set of actions in the event of a false condition. Conditions can be used in tasks, blocks, and loops in Ansible.
The "when" phrase is one of the most utilized conditionals in Ansible. We can provide a prerequisite that must be satisfied before a task is executed using the "when" expression. The "when" statement can be used, for instance, to determine whether a package is installed on a remote server before executing a process that depends on it. Here's an illustration:
---
- name: Install Apache web server
apt:
name: apache2
state: present
when: ansible_distribution == 'Ubuntu'
n this example, the task to install the Apache web server will only be executed if the remote server is running Ubuntu.
Conditionals can also be used in loops in Ansible. For example, we can use the "when" statement to filter the items in a loop based on a condition. Here's an example:
---
- name: Install multiple packages
apt:
name: "{{ item }}"
state: present
when: item in packages_to_install
loop: "{{ all_packages }}"
In this example, the task will only be executed for packages that are in the "packages_to_install" list.
▬▬▬▬▬▬ ⭐️ Time Stamps ⭐️ ▬▬▬▬▬▬
0:00 Intro
0:07 What is Ansible Conditional?
0:55 How to implement Ansible Conditional?
02:15 Multiple Conditional
03:44 Conditional on variable
05:41 Conditional with Loop
06:58 Ansible facts with Conditional
08:43 Demo
▬▬▬▬▬▬ ⭐️ Follow me ⭐️ ▬▬▬▬▬▬
Linkedin - https://www.linkedin.com/in/rahul-wagh/
Twitter - https://twitter.com/wagh_rahul
To learn more on DevOps visit - https://jhooq.com/
Learn more onto Anisble - https://www.ansible.com/
Disclaimer/Policy: All the content/instructions are solely mine. The source is completely open-source.
Video is copyrighted and can not be re-distributed on any platform.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Ansible when conditional explained - Part 9», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.