Skip to Content
Ansible: Up and Running, 3ª Edición
book

Ansible: Up and Running, 3ª Edición

by Bas Meijer, Lorin Hochstein, René Moser
September 2024
Intermediate to advanced
472 pages
11h 16m
Spanish
O'Reilly Media, Inc.
Content preview from Ansible: Up and Running, 3ª Edición

Capítulo 10. Libros de jugadas complejos

Este trabajo se ha traducido utilizando IA. Agradecemos tus opiniones y comentarios: translation-feedback@oreilly.com

En el capítulo anterior, vimos un libro de jugadas de Ansible completamente funcional para la implementación del CMS Mezzanine. Ese ejemplo utilizaba algunas funciones comunes de Ansible, pero no las cubría todas. Este capítulo aborda esas otras funciones, lo que lo convierte en una especie de bolsa de sorpresas.

Tratar con comandos que se comportan mal

Recuerda que en el Capítulo 7 evitamos invocar el comando personalizado createdb manage.py, mostrado en el Ejemplo 10-1, porque la llamada no era idempotente.

Ejemplo 10-1. Llamada a django manage.py createdb
- name: Initialize the database
  django_manage:
    command: createdb --noinput --nodata
    app_path: "{{ proj_path }}"
    virtualenv: "{{ venv_path }}"

Sorteamos este problema invocando varios comandos django manage.py que eran idempotentes, y que hacían el equivalente de createdb. Pero, ¿y si no tuviéramos un módulo que pudiera invocar comandos equivalentes? La respuesta es utilizar las cláusulas changed_when y failed_when para cambiar el modo en que Ansible detecta que una tarea ha cambiado de estado o ha fallado.

Vamos a asegurarnos de que entiendes la salida de este comando la primera y la segunda vez que se ejecuta.

Recuerda del Capítulo 5 que para capturar la salida de una tarea fallida, añades una cláusula register para guardar la salida en una variable y una cláusula ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Redes y Kubernetes

Redes y Kubernetes

James Strong, Vallery Lancey
Kubernetes: Up and Running, 3ª Edición

Kubernetes: Up and Running, 3ª Edición

Brendan Burns, Joe Beda, Kelsey Hightower, Lachlan Evenson

Publisher Resources

ISBN: 9781098182922