{"id":777,"date":"2019-10-16T12:41:58","date_gmt":"2019-10-16T12:41:58","guid":{"rendered":"http:\/\/imalogic.com\/blog\/?p=777"},"modified":"2019-10-16T12:41:58","modified_gmt":"2019-10-16T12:41:58","slug":"ansible-security-improvement","status":"publish","type":"post","link":"https:\/\/imalogic.com\/blog\/2019\/10\/16\/ansible-security-improvement\/","title":{"rendered":"Ansible, security improvement&#8230;"},"content":{"rendered":"<body>\n<p>Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intraservice orchestration and provisioning. Automation is crucial these days, with IT environments that are too complex and often need to scale too quickly for system administrators and developers to keep up if they had to do everything manually. Automation simplifies complex tasks, not just making developers\u2019 jobs more manageable but allowing them to focus attention on other tasks that add value to an organization. In other words, it frees up time and increases efficiency. And Ansible, as noted above, is rapidly rising to the top in the world of automation tools. Let\u2019s look at some of the reasons for Ansible\u2019s popularity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Advantages of Ansible<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Free<\/strong>. Ansible is an open-source tool.<\/li><li><strong>Very simple to set up and use<\/strong>. No special coding skills are necessary to use Ansible\u2019s playbooks (more on playbooks later).<\/li><li><strong>Powerful<\/strong>. Ansible lets you model even highly complex IT workflows.\u00a0<\/li><li><strong>Flexible<\/strong>. You can orchestrate the entire application environment no matter where it\u2019s deployed. You can also customize it based on your needs.<\/li><li><strong>Agentless<\/strong>. You don\u2019t need to install any other software or firewall ports on the client systems you want to automate. You also don\u2019t have to set up a separate management structure.<\/li><li><strong>Efficient<\/strong>. Because you don\u2019t need to install any extra software, there\u2019s more room for application resources on your server.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Security Improvement<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"781\" data-permalink=\"https:\/\/imalogic.com\/blog\/2019\/10\/16\/ansible-security-improvement\/lock\/\" data-orig-file=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/Lock.jpg?fit=1309%2C1084&amp;ssl=1\" data-orig-size=\"1309,1084\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Lock\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/Lock.jpg?fit=810%2C671&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/Lock.jpg?resize=479%2C397&#038;ssl=1\" alt=\"\" class=\"wp-image-781\" width=\"479\" height=\"397\" loading=\"lazy\" srcset=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/Lock.jpg?resize=1024%2C848&amp;ssl=1 1024w, https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/Lock.jpg?resize=300%2C248&amp;ssl=1 300w, https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/Lock.jpg?resize=768%2C636&amp;ssl=1 768w, https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/Lock.jpg?w=1309&amp;ssl=1 1309w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/figure><\/div>\n\n\n\n<p>For a mission to one of my clients, Ansible was used to make security auditing tools, for that some security improvement was done by using the engine specific features: privilege escalation to avoid a ssh connection using super-user, a \u201cvault\u201d to store sensible information\u2019s like credentials\u2026 <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Privilege Escalation<\/h4>\n\n\n\n<p>Some Network Element (NE) Specific script needs to have access to some commands with high privilege.<\/p>\n\n\n\n<p>Ansible\nallows you to \u2018become\u2019 another user, different from the user that logged into\nthe machine (remote user). This is done using existing privilege escalation\ntools such as\u00a0sudo,\u00a0su,\u00a0pfexec,\u00a0doas,\u00a0pbrun,\u00a0dzdo,\u00a0ksu,\u00a0runas,\u00a0machinectl\u00a0and others.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"810\" height=\"434\" data-attachment-id=\"779\" data-permalink=\"https:\/\/imalogic.com\/blog\/2019\/10\/16\/ansible-security-improvement\/tt\/\" data-orig-file=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tt.png?fit=932%2C499&amp;ssl=1\" data-orig-size=\"932,499\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"tt\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tt.png?fit=810%2C434&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tt.png?resize=810%2C434&#038;ssl=1\" alt=\"\" class=\"wp-image-779\" loading=\"lazy\" srcset=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tt.png?w=932&amp;ssl=1 932w, https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tt.png?resize=300%2C161&amp;ssl=1 300w, https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tt.png?resize=768%2C411&amp;ssl=1 768w\" sizes=\"auto, (max-width: 810px) 100vw, 810px\" \/><\/figure><\/div>\n\n\n\n<p>The above situation comes with the security policy of the company. Allowing people to ssh to remote as super-user will expose the password of the super-user, which could be a potential security risk.<br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Usage of vault<\/h4>\n\n\n\n<p>At the first step of\ndevelopment, the audit tool engine uses a config file (host.ini) to store all\nNE address and specifics variables credentials associated. <\/p>\n\n\n\n<p>In the second step of\ndevelopment, for security improvement, the specifics variables credentials can\nbe crypted and stored inside a Vault.\u00a0 <\/p>\n\n\n\n<p>Vault is a feature of\nansible that allows keeping sensitive data such as passwords or keys in\nencrypted files rather than as plaintext in playbooks or roles. AES-256\nalgorithm is used to encrypt, the variables are decrypted on runtime.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"772\" height=\"363\" data-attachment-id=\"778\" data-permalink=\"https:\/\/imalogic.com\/blog\/2019\/10\/16\/ansible-security-improvement\/tech-blog-muzi1\/\" data-orig-file=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tech-blog-muzi1.png?fit=772%2C363&amp;ssl=1\" data-orig-size=\"772,363\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"tech-blog-muzi1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tech-blog-muzi1.png?fit=772%2C363&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tech-blog-muzi1.png?resize=772%2C363&#038;ssl=1\" alt=\"\" class=\"wp-image-778\" loading=\"lazy\" srcset=\"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tech-blog-muzi1.png?w=772&amp;ssl=1 772w, https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tech-blog-muzi1.png?resize=300%2C141&amp;ssl=1 300w, https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/tech-blog-muzi1.png?resize=768%2C361&amp;ssl=1 768w\" sizes=\"auto, (max-width: 772px) 100vw, 772px\" \/><\/figure>\n\n\n\n<p>Usage of Ansible-Vault to store sensible variables.<\/p>\n\n\n\n<p>Below,\nthe\u00a0result example of ansible-vault encrypt\u00a0command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>the_secret_variable: !vault |\n      $ANSIBLE_VAULT;1.1;AES256\n      62313365396662343061393464336163383764373764613633653634306231386433626436623361\n      6134333665353966363534333632666535333761666131620a663537646436643839616531643561\n      63396265333966386166373632626539326166353965363262633030333630313338646335303630\n      3438626666666137650a353638643435666633633964366338633066623234616432373231333331\n      6564<\/code><\/pre>\n\n\n\n<p>The management of the\nvault (create\/edit\/encrypt variables) should be done by a security officer.<\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intraservice orchestration<\/p>\n","protected":false},"author":1,"featured_media":782,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[86,87,81],"class_list":["post-777","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-ansible","tag-devops","tag-security"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/imalogic.com\/blog\/wp-content\/uploads\/2019\/10\/images.png?fit=224%2C225&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8J21V-cx","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/posts\/777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/comments?post=777"}],"version-history":[{"count":1,"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/posts\/777\/revisions"}],"predecessor-version":[{"id":783,"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/posts\/777\/revisions\/783"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/media\/782"}],"wp:attachment":[{"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/media?parent=777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/categories?post=777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imalogic.com\/blog\/wp-json\/wp\/v2\/tags?post=777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}