{"id":71410,"date":"2023-02-21T09:01:11","date_gmt":"2023-02-21T09:01:11","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=71410"},"modified":"2023-02-21T09:01:11","modified_gmt":"2023-02-21T09:01:11","slug":"automate-openstack-using-ansible","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=71410","title":{"rendered":"Automate OpenStack using Ansible"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">Automate OpenStack using Ansible<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/ajscanlas\" class=\"username\">ajscanlas<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Tue, 02\/21\/2023 &#8211; 03:00<\/span><\/p>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>I demonstrated how I manage OpenStack using Terraform in my <a href=\"https:\/\/opensource.com\/article\/23\/2\/manage-openstack-using-terraform-and-gitlab\" target=\"_blank\" rel=\"noopener\">previous article<\/a>. Using Terraform as Infrastructure as Code (IaC) is a significant advantage, but it also requires the staff to support it. Sometimes, all you really need is the ability to provision infrastructure as timed resources, with no intention of building lasting data structures. When I design a flexible environment, I prefer the declarative language of Ansible.<\/p>\n<p>Ansible&#8217;s flexibility allows me to design for use cases that include:<\/p>\n<ol>\n<li>A test environment that&#8217;s timed and can be deleted after use.<\/li>\n<li>A training environment provided for a specific amount of time and then destroyed.<\/li>\n<li>Moving from a manual to an automated infrastructure when Terraform is difficult because it maps your existing infrastructure.<\/li>\n<\/ol>\n<h2>Install Ansible and OpenStack SDK<\/h2>\n<p>First, you need to install Ansible and its SDK. For this, you must have Docker or <a href=\"https:\/\/www.redhat.com\/sysadmin\/topics\/podman?intcmp=7013a000002qLH8AAM\" target=\"_blank\" rel=\"noopener\">Podman<\/a> installed.<\/p>\n<p>I use the <a href=\"https:\/\/www.redhat.com\/sysadmin\/install-python-pip-linux?intcmp=7013a000002qLH8AAM\" target=\"_blank\" rel=\"noopener\">pip<\/a> installation of Ansible:<\/p>\n<pre>\n<code class=\"language-shell\">$ python3 -m pip install ansible-navigator --user<\/code><\/pre>\n<p>The <code>ansible-navigator<\/code> command gets used by AWX or Red Hat Ansible Automation Platform to run Ansible playbooks. Unlike the previous <code>ansible-playbook<\/code> or <code>ansible<\/code> ad-hoc commands, this creates a container and execution environment.<\/p>\n<p>You must build your execution environment with an OpenStack SDK. For this, I strongly recommend the article by Gineesh Madapparambath on <a href=\"https:\/\/www.redhat.com\/sysadmin\/ansible-execution-environment-unconnected?intcmp=7013a000002qLH8AAM\" target=\"_blank\" rel=\"noopener\">how to create an execution environment<\/a>.<\/p>\n<p>After creation, use your Ansible execution environment to configure your image:<\/p>\n<pre>\n<code class=\"language-shell\">$ ansible-navigator images<\/code><\/pre>\n<p>Choose which image to use and run a playbook:<\/p>\n<pre>\n<code class=\"language-shell\">$ ansible-navigator run main.yaml --stdout<\/code><\/pre>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">More on Ansible<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/resources\/why-migrate-ansible-automation-platform-2-checklist?intcmp=701f2000000h4RcAAI\">5 reasons to migrate to Red Hat Ansible Automation Platform 2<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/ansible-quickstart?intcmp=701f2000000h4RcAAI\">A quickstart guide to Ansible<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/ansible-cheat-sheet?intcmp=701f2000000h4RcAAI\">Ansible cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/do007-ansible-essentials-simplicity-automation-technical-overview?intcmp=701f2000000h4RcAAI\">Free online course: Ansible essentials<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/intro_installation.html?intcmp=701f2000000h4RcAAI\">Download and install Ansible<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/go.redhat.com\/automated-enterprise-ebook-20180920?intcmp=701f2000000h4RcAAI\">eBook: The automated enterprise<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.ansible.com\/resources\/ebooks\/ansible-for-devops?intcmp=701f2000000h4RcAAI\">eBook: Ansible for DevOps<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.ansible.com\/resources\/ebooks?intcmp=701f2000000h4RcAAI\">Free Ansible eBooks<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/ansible?intcmp=701f2000000h4RcAAI\">Latest Ansible articles<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h2>Sample playbook<\/h2>\n<p>My sample playbook uses the same structure I demonstrated in my Terraform article:<\/p>\n<pre>\n<code class=\"language-yaml\">$ cat &gt;&gt; main.yaml <\/code><\/pre>\n<h2>Results<\/h2>\n<p>After you run the playbook, you get networks:<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2023\/02\/network.png\" width=\"1200\" height=\"394\" alt=\"Network settings\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(AJ Canlas, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p>You also get flavors:<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2023\/02\/flavors.png\" width=\"1200\" height=\"440\" alt=\"flavors\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(AJ Canlas, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p>And images:<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2023\/02\/images.png\" width=\"1200\" height=\"426\" alt=\"images\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(AJ Canlas, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p>And a demo project:<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2023\/02\/projects.png\" width=\"1200\" height=\"366\" alt=\"projects\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(AJ Canlas, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<h2>The right tool<\/h2>\n<p>There&#8217;s no single right or wrong answer for how you automate. How you implement your automation depends on your organization&#8217;s needs, infrastructure, system design, and staff resources. Select one of the great open source tools out there to get started. Put in the effort now, and save yourself a lot of work in the future.<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>Ansible offers unique flexibility when automating your infrastructure.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2023\/02\/tips_map_guide_ebook_help_troubleshooting_lightbulb_520.png\" width=\"520\" height=\"292\" alt=\"Looking at a map\" title=\"Looking at a map\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>opensource.com<\/p>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/openstack\" hreflang=\"en\">OpenStack<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/ansible\" hreflang=\"en\">Ansible<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/cloud\" hreflang=\"en\">Cloud<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/automation\" hreflang=\"en\">Automation<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-listicles field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/article\/23\/1\/automate-terraform-gitops\" hreflang=\"en\">How to use GitOps to automate Terraform<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2023\/02\/cc-by-sa--31.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?destination=\/feed&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Automate OpenStack using Ansible ajscanlas Tue, 02\/21\/2023 &#8211; 03:00 I demonstrated how I manage OpenStack using Terraform in my previous article. Using Terraform as Infrastructure as Code (IaC) is a significant advantage, but it also requires the staff to support it. Sometimes, all you really need is the ability to provision infrastructure as timed resources, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":71411,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-71410","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/71410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71410"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/71410\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/71411"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}