{"id":1783,"date":"2020-12-17T20:15:00","date_gmt":"2020-12-17T19:15:00","guid":{"rendered":"https:\/\/robermb.com\/blog\/?p=1783"},"modified":"2020-12-22T17:54:37","modified_gmt":"2020-12-22T16:54:37","slug":"configure-ssl-https-on-ansible-awx","status":"publish","type":"post","link":"https:\/\/robermb.com\/blog\/geeks\/configure-ssl-https-on-ansible-awx\/","title":{"rendered":"Ansible AWX: How to configure SSL\/HTTPs"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Initial situation, HTTP :<\/h3>\n\n\n\n<p>We have an <strong>standalone <\/strong>instance of <strong>Ansible AWX<\/strong>(Docker version) already installed in a CentOS linux machine.<\/p>\n\n\n\n<p>The <strong>web container <\/strong>called <strong>awx_web<\/strong>, is configured with <strong>http<\/strong>, port 80.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker ps\nCONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                  NAMES\nbb3053c6cd38        ansible\/awx:13.0.0   \"tini -- \/bin\/sh -c \u2026\"   7 days ago          Up 6 days           0.0.0.0:<strong>80<\/strong>-&gt;8052\/tcp   <strong>awx_web<\/strong><\/code><\/pre>\n\n\n\n<p>And the values into <strong>inventory file <\/strong>related to SSL are still commented :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># vi \/opt\/ansible-awx\/awx\/installer\/inventory<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>host_port=80\n#host_port_ssl=443\n#ssl_certificate=<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure SSL \/ HTTPs<strong> :<\/strong><\/h3>\n\n\n\n<p>In a <strong>testing Lab <\/strong>environment we need to <strong>create <\/strong>a <strong>self-signed certificate<\/strong>. <\/p>\n\n\n\n<p>Create <strong>awx-ssl<\/strong> <strong>folder <\/strong>in \/opt\/ansible-awx\/awx\/installer :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># mkdir -p \/opt\/ansible-awx\/awx\/installer\/awx-ssl\n<\/code><\/pre>\n\n\n\n<p><strong>Generate <\/strong>a <strong>self-signed SSL certificate<\/strong> with your own information :<\/p>\n\n\n\n<p><strong>CN <\/strong>: Common Name<br><strong>O <\/strong>: Organization<br><strong>C <\/strong>: Country<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># openssl req -subj '\/CN=ansible.awx\/O=Lab\/C=FR' \\\n\t-new -newkey rsa:2048 \\\n\t-sha256 -days 1365 \\\n\t-nodes -x509 \\\n\t-keyout \/opt\/ansible-awx\/awx\/installer\/awx-ssl\/awx.key \\\n\t-out \/opt\/ansible-awx\/awx\/installer\/awx-ssl\/\/awx.crt\n<\/code><\/pre>\n\n\n\n<p><strong>Merge awx.key<\/strong> and <strong>awx.crt<\/strong> files into a final certificate file called <strong>awx-self-signed-key.crt<\/strong> :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd \/opt\/ansible-awx\/awx\/installer\/awx-ssl\n# cat awx.key  awx.crt &gt; awx-self-signed-key.crt\n<\/code><\/pre>\n\n\n\n<p><strong>Modify <\/strong>the Ansible AWX <strong>inventory file <\/strong>to configure our ssl certificate :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># vi \/opt\/ansible-awx\/awx\/installer\/inventory<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#host_port=80\nhost_port_ssl=443\nssl_certificate=\/opt\/ansible-awx\/awx\/installer\/awx-ssl\/awx-self-signed-key.crt<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Relaunch Ansible AWX Installation Playbook :<\/strong><\/h3>\n\n\n\n<p>To <strong>reconfigure <\/strong>the <strong>web container<\/strong>(awx_web) with the <strong>SSL <\/strong>new <strong>parameters<\/strong>, it&#8217;s necessary to <strong>relaunch <\/strong>the <strong>installation <\/strong>command to apply all the changes into the container, more specifically, to modify the nginx web server configuration inside the container. <\/p>\n\n\n\n<p>Execute the following :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd \/opt\/ansible-awx\/awx\/installer\n# ansible-playbook -i inventory install.yml\n<\/code><\/pre>\n\n\n\n<p>Now  the <strong>web container <\/strong>called <strong>awx_web<\/strong>, is configured with <strong>https<\/strong>, port <strong>443<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker ps\nCONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                                         NAMES\n9d01d5daa7da        ansible\/awx:13.0.0   \"tini -- \/bin\/sh -c \u2026\"   10 minutes ago      Up 10 minutes        0.0.0.0:<strong>443<\/strong>-&gt;8053\/tcp   <strong>awx_web<\/strong><\/code><\/pre>\n\n\n\n<p>And the Ansible AWX instance can be accessible by <strong>https <\/strong>: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;&#91;ANSIBLE_AWX_INSTANCE]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Quick verification<\/h3>\n\n\n\n<p>We can check just <strong>inside <\/strong>the <strong>awx_web container<\/strong>, and see that there is our certificate file but with the name <strong>awxweb.pem<\/strong> :<\/p>\n\n\n\n<p>Access to web container :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker exec -ti awx_web \/bin\/bash\n<\/code><\/pre>\n\n\n\n<p>Check file certificate :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd \/etc\/nginx\n# ls -l awxweb.pem\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Initial situation, HTTP : We have an standalone instance of Ansible AWX(Docker version) already installed in a CentOS linux machine. &hellip; <a href=\"https:\/\/robermb.com\/blog\/geeks\/configure-ssl-https-on-ansible-awx\/\" class=\"more-link\">More <span class=\"screen-reader-text\">Ansible AWX: How to configure SSL\/HTTPs<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1808,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[103,2],"tags":[106,111,114,113],"_links":{"self":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts\/1783"}],"collection":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/comments?post=1783"}],"version-history":[{"count":6,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts\/1783\/revisions"}],"predecessor-version":[{"id":1802,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts\/1783\/revisions\/1802"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/media\/1808"}],"wp:attachment":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/media?parent=1783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/categories?post=1783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/tags?post=1783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}