{"id":1451,"date":"2021-11-18T09:21:53","date_gmt":"2021-11-18T09:21:53","guid":{"rendered":"https:\/\/blog.amt.in\/?p=1451"},"modified":"2021-11-18T09:21:53","modified_gmt":"2021-11-18T09:21:53","slug":"introduction-to-ansible","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2021\/11\/18\/introduction-to-ansible\/","title":{"rendered":"Introduction to Ansible"},"content":{"rendered":"<p>Ansible\u00c2\u00a0is an\u00c2\u00a0open-source\u00c2\u00a0software provisioning, configuration management, and\u00c2\u00a0application-deployment\u00c2\u00a0tool.\u00c2\u00a0It runs on many\u00c2\u00a0Unix-like\u00c2\u00a0systems, and can configure both Unix-like systems as well as\u00c2\u00a0Microsoft Windows. It includes its own\u00c2\u00a0declarative language\u00c2\u00a0to describe\u00c2\u00a0system configuration. Ansible was written by Michael DeHaan and acquired by\u00c2\u00a0Red Hat\u00c2\u00a0in 2015. Ansible is\u00c2\u00a0agentless, temporarily connecting remotely via\u00c2\u00a0SSH\u00c2\u00a0or\u00c2\u00a0Windows Remote Management\u00c2\u00a0(allowing remote\u00c2\u00a0PowerShell\u00c2\u00a0execution) to do its tasks.<\/p>\n<p>Unlike most configuration-management software, Ansible does not require a single controlling machine where orchestration begins. Ansible works against multiple systems in your infrastructure by selecting portions of Ansible\u00e2\u20ac\u2122s inventory, stored as edit-able, version-able ASCII text files. Not only is this inventory configurable, but you can also use multiple inventory files at the same time and pull inventory from dynamic or cloud sources or different formats (YAML,\u00c2\u00a0INI, etc). Any machine with Ansible utilities installed can leverage a set of files\/directories to orchestrate other nodes. The absence of a central-server requirement greatly simplifies disaster-recovery planning. Nodes are managed by this controlling machine &#8211; typically over SSH. The controlling machine describes the location of nodes through its\u00c2\u00a0inventory.\u00c2\u00a0Sensitive data can be stored in encrypted files using Ansible Vault\u00c2\u00a0since 2014.\u00c2\u00a0In contrast with other popular configuration-management software \u00e2\u20ac\u201d such as\u00c2\u00a0Chef,\u00c2\u00a0Puppet, and\u00c2\u00a0CFEngine\u00c2\u00a0\u00e2\u20ac\u201d Ansible uses an\u00c2\u00a0agentless\u00c2\u00a0architecture,\u00c2\u00a0with Ansible software not normally running or even installed on the controlled node.\u00c2\u00a0Instead, Ansible orchestrates a node by installing and running modules on the node temporarily via SSH. For the duration of an orchestration task, a process running the module communicates with the controlling machine with a\u00c2\u00a0JSON-based protocol via its standard input and output.\u00c2\u00a0When Ansible is not managing a node, it does not consume resources on the node because no daemons are executing of software installed.<\/p>\n<p><span id=\"Design_goals\" class=\"mw-headline\">Design goals:<\/span><\/p>\n<p>The design goals of Ansible include:<\/p>\n<ul>\n<li>Minimal in nature. Management systems should not impose additional dependencies on the environment.<\/li>\n<li>Consistent. With Ansible one should be able to create consistent environments.<\/li>\n<li>Secure. Ansible does not deploy agents to nodes. Only\u00c2\u00a0OpenSSH\u00c2\u00a0and\u00c2\u00a0Python\u00c2\u00a0are required on the managed nodes.<\/li>\n<li>Highly reliable. When carefully written, an Ansible\u00c2\u00a0playbook\u00c2\u00a0can be\u00c2\u00a0idempotent, to prevent unexpected side-effects on the managed systems. It is entirely possible to have a poorly written playbook that is not idempotent.<\/li>\n<li>Minimal learning required. Playbooks use an easy and descriptive language based on\u00c2\u00a0YAML\u00c2\u00a0and\u00c2\u00a0Jinja templates.<\/li>\n<\/ul>\n<p><span id=\"Modules\" class=\"mw-headline\">Modules:<\/span><\/p>\n<p>Modules\u00c2\u00a0are mostly standalone and can be written in a standard scripting language (such as Python, Perl, Ruby, Bash, etc.). One of the guiding properties of modules is\u00c2\u00a0idempotency, which means that even if an operation is repeated multiple times (e.g., upon recovery from an outage), it will always place the system into the same state.<\/p>\n<p><span id=\"Inventory_configuration\" class=\"mw-headline\">Inventory configuration:<\/span><\/p>\n<p>The Inventory is a description of the nodes that can be accessed by Ansible. By default, the Inventory is described by a configuration file, in\u00c2\u00a0INI\u00c2\u00a0or\u00c2\u00a0YAML\u00c2\u00a0format,\u00c2\u00a0whose default location is in\u00c2\u00a0<code>\/etc\/ansible\/hosts<\/code>. The configuration file lists either the IP address or\u00c2\u00a0hostname\u00c2\u00a0of each node that is accessible by Ansible. In addition, nodes can be assigned to groups.<\/p>\n<p><span id=\"Playbooks\" class=\"mw-headline\">Playbooks:<\/span><\/p>\n<p>Playbooks are\u00c2\u00a0YAML\u00c2\u00a0files that express configurations, deployment, and orchestration in Ansible,\u00c2\u00a0and allow Ansible to perform operations on managed nodes. Each Playbook maps a group of hosts to a set of roles. Each role is represented by calls to Ansible tasks.<\/p>\n<p><span id=\"Ansible_Tower\" class=\"mw-headline\">Ansible Tower:<\/span><\/p>\n<p><span id=\"AWX\"><\/span>Ansible Tower is a\u00c2\u00a0REST API,\u00c2\u00a0web service, and web-based console designed to make Ansible more usable for IT teams with members of different technical proficiencies and skill sets. It is a hub for automation tasks. Tower is a commercial product supported by Red Hat, Inc. but derived from AWX upstream project, which is open source since September 2017.<\/p>\n<p>There is also another open source alternative to Tower,\u00c2\u00a0Semaphore, written in\u00c2\u00a0Go.<\/p>\n<p>Control machines have to be a Linux\/Unix host (for example\u00c2\u00a0SUSE Linux Enterprise,\u00c2\u00a0Red Hat Enterprise Linux,\u00c2\u00a0Debian,\u00c2\u00a0CentOS,\u00c2\u00a0macOS,\u00c2\u00a0BSD,\u00c2\u00a0Ubuntu), and Python 2.7 or 3.5 is required.<\/p>\n<p>Managed nodes, if they are Unix-like, must have Python 2.4 or later. For managed nodes with Python 2.5 or earlier, the\u00c2\u00a0<code>python-simplejson<\/code>\u00c2\u00a0package is also required.\u00c2\u00a0Since version 1.7, Ansible can also manage\u00c2\u00a0Windows\u00c2\u00a0nodes.\u00c2\u00a0In this case, native PowerShell remoting supported by the WS-Management protocol is used, instead of SSH.<\/p>\n<p>The above is a brief about Ansible. Watch this space for more updates on the latest trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ansible\u00c2\u00a0is an\u00c2\u00a0open-source\u00c2\u00a0software provisioning, configuration management,<\/p>\n","protected":false},"author":1,"featured_media":1452,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[642,643,7],"tags":[644,645,18],"class_list":["post-1451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible","category-open-source-software","category-techtrends","tag-ansible","tag-open-source-software","tag-technology"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=1451"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1451\/revisions"}],"predecessor-version":[{"id":1453,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1451\/revisions\/1453"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/1452"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=1451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=1451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=1451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}