{"id":1469,"date":"2022-05-19T09:57:22","date_gmt":"2022-05-19T09:57:22","guid":{"rendered":"https:\/\/www.nicktailor.com\/?p=1469"},"modified":"2022-10-21T12:06:21","modified_gmt":"2022-10-21T12:06:21","slug":"how-to-pass-an-api-key-with-ansible","status":"publish","type":"post","link":"https:\/\/nicktailor.com\/tech-blog\/how-to-pass-an-api-key-with-ansible\/","title":{"rendered":"How to pass an API key with Ansible"},"content":{"rendered":"<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong><span style=\"color: #002060;\">https:\/\/chronosphere.io\/ &#8211; Third Party Cloud Monitoring Solution<\/span><\/strong><\/p>\n<p><strong>Chronocollector<\/strong><span style=\"color: #002060;\">: &#8211; <\/span><a href=\"https:\/\/github.com\/Perfect10NickTailor\/chronocollector\"><span style=\"text-decoration: underline; color: #0563c1;\">https:\/\/github.com\/Perfect10NickTailor\/chronocollector<\/span><\/a><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #002060;\">This role deploys the chronocollector management service which sends the data to <\/span><span style=\"color: #c00000;\">domain.chronosphere.io<\/span><span style=\"color: #002060;\"> For those of you who don\u2019t know what it is. Its basically a <\/span><span style=\"color: #00b0f0;\">cloud monitoring tool<\/span><span style=\"color: #002060;\"> that scrapes data on your instances and then you can create dashboards or even export the data to promethus to make it look pretty and easy to read. You will likely pay for subscription, they will give you a subdomain which becomes your gateway address (domain.<\/span>chronosphere.io)<\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #ff0000;\">Special note: You then need to deploy the node_exporter to push to the hosts you want scraped. That is a separate playbook and stupid easy.<\/span><\/p>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: initial; color: #002060; background-color: #auto;\">\u25cf<\/span><span style=\"color: #002060; background-color: #auto;\">This role will download the latest collector<\/span><\/div>\n<\/div>\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: initial; color: #002060; background-color: #auto;\">\u25cf<\/span><span style=\"color: #002060; background-color: #auto;\">It will install the latest collector<\/span><\/div>\n<\/div>\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: initial; color: #002060; background-color: #auto;\">\u25cf<\/span><span style=\"color: #002060; background-color: #auto;\">It will check to see if the &#8216;service&#8217; its added to systemd, if nots.. adds it, if the service is there, it will move on and simply start the service.<\/span><\/div>\n<\/div>\n<\/div>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">#nowthatsjustfunny<\/span><span style=\"color: #002060;\">: So its debatable on how to approach passing {{ api_keys }} in a scalable and secure way. A lot of people create an <\/span><span style=\"color: #00b0f0;\">\u201cansible vault encrypted variable\u201d. <\/span><span style=\"color: #000000;\">This is so that when they push their code to their git repos. The {{ api_key }} isn\u2019t exposed to someone simply glancing by the code. <\/span><span style=\"color: #c00000;\">The issue with this approach is now you have to remember a vault password to pass to ansible, so it can decrypt the {{ api_key }} to pass, inorder for it to work when you run the playbook.<\/span><span style=\"color: #ff0000;\">(LAME)<\/span><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">#nowthatsjustcool:<\/span><span style=\"color: #000000;\"> So just for the purposes of this post and for fun. I wrote it so that you can simply pass the {{ api_key }} during runtime. This way instead of being prompted for the vault-pass, you are prompted for the api_key to pass as a variable when you run the book.<\/span> <span style=\"color: #c00000;\">This gets rid of the need to setup a encrypted variable in your code entirely. <\/span><span style=\"color: #000000;\">Everyone has their own way of doing things, but I tend to think outside the box, so it always way more fun to be different in how you think.<br \/>\n<\/span><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong><span style=\"color: #00b0f0;\">Ansible Operational Documentation<\/span><\/strong><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #002060;\">How to use this role:<\/span><\/p>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 10pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: initial; color: #000000; background-color: #auto;\">1.<\/span><span style=\"color: #002060; background-color: #auto;\">You must first download the git repository <\/span><\/div>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 72pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: italic; font-weight: initial; color: #000000; background-color: #auto;\">a.<\/span><span style=\"color: #002060; background-color: #auto;\"><em>git clone git@github.com:Perfect10NickTailor\/chronocollector.git<\/em><\/span><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; color: #000000; font-size: 10pt;\">2.<\/span><span style=\"color: #000000; background-color: #auto;\">Under your user you will see a directory called <\/span><strong><span style=\"color: #000000; background-color: #auto;\">chronocollector<\/span><\/strong><span style=\"color: #000000; background-color: #auto;\"> cd into this directory here you will see the <\/span><span style=\"color: #c00000; background-color: #auto;\">defaults\/main.yml<\/span><span style=\"color: #000000; background-color: #auto;\"> where you can see what you can pass to <\/span><span style=\"color: #7030a0; background-color: #auto;\">groups_vars &amp; host_vars<br \/>\n<\/span><\/div>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2; margin-left: 72pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: italic; font-weight: initial; color: #000000; background-color: #auto;\">b.<\/span><span style=\"color: #000000; background-color: #auto;\"><em>cd chronocollector<\/em><\/span><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 10pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: initial; color: #000000; background-color: #auto;\">3.<\/span><span style=\"color: #002060; background-color: #auto;\">Next you want edit the <\/span><span style=\"color: #7030a0; background-color: #auto;\">hosts.client<\/span><span style=\"color: #002060; background-color: #auto;\"> inside your <\/span><span style=\"color: #c00000; background-color: #auto;\">ansible\/inventory\/dev\/hosts.client<\/span><\/div>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"color: #002060;\">Example file<\/span><span style=\"color: #0070c0;\">: hosts.dev <\/span><span style=\"color: #00b0f0;\">or <\/span><span style=\"color: #0070c0;\">hosts.staging<\/span><\/p>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3; margin-left: 72pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: initial; color: #000000; background-color: #auto;\">c.<\/span><span style=\"color: #002060; background-color: #auto;\">Put your server under the appropriate group inside the file and save<\/span><\/div>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 108pt;\"><span style=\"display: inline-block; position: relative; text-indent: -9pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: italic; font-weight: initial; color: #0070c0; background-color: #auto;\">i.<\/span><span style=\"color: #0070c0; background-color: #auto;\"><em>Testmachine1 ansible_host=192.168.60.10<\/em><\/span><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong><span style=\"color: #002060;\">Running your playbook: <\/span><\/strong><\/p>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: bold; color: #002060; background-color: #auto;\">1.<\/span><strong><span style=\"color: #002060; background-color: #auto;\">You must run your play book from inside parent ansible directory<\/span><\/strong><\/div>\n<\/div>\n<\/div>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 18pt;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<div class=\"ol\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; text-transform: initial; font-size: 11pt; text-decoration: initial; vertical-align: initial; font-style: initial; font-weight: bold; color: #002060; background-color: #auto;\">2.<\/span><strong><span style=\"color: #002060; background-color: #auto;\">Now there is a playbook called <\/span><\/strong><a href=\"https:\/\/github.com\/Perfect10NickTailor\/chronocollector\/blob\/main\/choronocollector\/chronocollector-agent.yml\"><span style=\"text-decoration: underline; color: #0563c1; background-color: #auto;\">chronocollector.yml<\/span><\/a><strong> <span style=\"color: #002060; background-color: #auto;\">in the <\/span><span style=\"color: #00b0f0; background-color: #auto;\">ansible<\/span><span style=\"color: #002060; background-color: #auto;\"> directory which simply calls the <\/span><span style=\"color: #00b0f0; background-color: #auto;\">chronocollector<\/span><span style=\"color: #002060; background-color: #auto;\"> role inside the <\/span><span style=\"color: #0070c0; background-color: #auto;\">ansible\/roles\/chronocollector<\/span><span style=\"color: #002060; background-color: #auto;\"> directory, where the role should be living.<\/span><\/strong><\/div>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><strong><span style=\"color: #c00000;\">Example: of ansible\/<\/span><\/strong><a href=\"https:\/\/github.com\/Perfect10NickTailor\/chronocollector\/blob\/main\/choronocollector\/chronocollector-agent.yml\"><strong><span style=\"text-decoration: underline; color: #c00000;\">chronocollector.yml<\/span><\/strong><\/a><\/p>\n<\/div>\n<\/div>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #d4d4d4;\">&#8211; <\/span><span style=\"color: #569cd6;\">hosts<\/span><span style=\"color: #d4d4d4;\">: <\/span><span style=\"color: #ce9178;\">all<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #d4d4d4;\">\u00a0\u00a0<\/span><span style=\"color: #569cd6;\">gather_facts<\/span><span style=\"color: #d4d4d4;\">: <\/span><span style=\"color: #569cd6;\">no<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #d4d4d4;\">\u00a0\u00a0<\/span><span style=\"color: #569cd6;\">vars_prompt<\/span><span style=\"color: #d4d4d4;\">:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #d4d4d4;\">\u00a0 &#8211; <\/span><span style=\"color: #569cd6;\">name<\/span><span style=\"color: #d4d4d4;\">: <\/span><span style=\"color: #ce9178;\">api_key<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #d4d4d4;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #569cd6;\">prompt<\/span><span style=\"color: #d4d4d4;\">: <\/span><span style=\"color: #ce9178;\">Enter the API key<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #d4d4d4;\">\u00a0\u00a0<\/span><span style=\"color: #569cd6;\">roles<\/span><span style=\"color: #d4d4d4;\">: <\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #d4d4d4;\">\u00a0 \u00a0 &#8211; <\/span><span style=\"color: #569cd6;\">role<\/span><span style=\"color: #d4d4d4;\">: <\/span><span style=\"color: #ce9178;\">chronocollector<\/span><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong><span style=\"color: #002060;\">Command:<\/span><\/strong><\/p>\n<p style=\"text-align: justify; margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong><span style=\"color: #002060;\">ansible-playbook -i inventory\/dev\/hosts.dev chronocollector.yml -u nickadmin -Kkb &#8211;ask-become &#8211;limit=&#8217;testmachine3&#8242;<\/span><\/strong><\/p>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2; margin-left: 18pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; color: #000000;\">\u25cf<\/span><span style=\"color: #000000; background-color: #auto;\">-i : This flag tells ansibe-playbook command which hosts file to use, these are always defined by customer like <\/span><strong><span style=\"color: #000000; background-color: #auto;\">hosts.dev<\/span><\/strong><span style=\"color: #000000; background-color: #auto;\"> or <\/span><strong><span style=\"color: #000000; background-color: #auto;\">hosts.staging<\/span><\/strong><\/div>\n<\/div>\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2; margin-left: 18pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; color: #000000;\">\u25cf<\/span><span style=\"color: #000000; background-color: #auto;\">-u : this is the ssh_user you will be connecting to the servers with<\/span><\/div>\n<\/div>\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2; margin-left: 18pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; color: #000000;\">\u25cf<\/span><span style=\"color: #000000; background-color: #auto;\">-Kkb : this tells ansible that you will be using sudo su \u2013 for the ssh_user when running all role\/tasks<\/span><\/div>\n<\/div>\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2; margin-left: 18pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; color: #000000;\">\u25cf<\/span><span style=\"color: #000000; background-color: #auto;\">-ask-beocme : is saying become root<\/span><\/div>\n<\/div>\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2; margin-left: 18pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; color: #000000;\">\u25cf<\/span><span style=\"color: #000000; background-color: #auto;\">-limit=\u2019server\u2019 : this allows you to segement which server you want to run the playbook against.<\/span><\/div>\n<\/div>\n<\/div>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #000000; background-color: #auto;\">Successful run: <\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #7030a0; background-color: #auto;\">Notice: It asks you for the API key at runtime.<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">ntailor@jumphost:~\/ansible2$ ansible-playbook -i ansible\/inventory\/dev\/hosts.dev chronocollector.yml -u nicktadmin -Kkb &#8211;ask-become &#8211;limit=&#8217;testmachine3&#8242;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">SSH password: <\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">BECOME password[defaults to SSH password]: <\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #7030a0;\">Enter the API key: <\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">PLAY [all] ***************************************************************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : download node collector] *************************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">ok: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : move collector to \/usr\/local\/bin] ****************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">ok: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : mkdir directory \/etc\/chronocollector] ************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">ok: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Copy default config.yml to \/etc\/chronocollector\/] ************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">ok: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Touch again the same file, but do not change times this makes the task idempotent] ***************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Ensure API key is present in config file] ********************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Change file ownership, group and permissions apitoken file to secure it from prying eyes other than root] ****************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Check that the service file \/etc\/systemd\/system\/collector.service exists] ************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">ok: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Include add systemd task if service file does not exist] *****************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">included: ansible\/roles\/chronocollector\/tasks\/systemd.yml for testmachine3<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Create startup file for collector in systemd] ****************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Create systemd collector.service] ****************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : check whether custom line exists] ****************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Start Collector Service via systemd] *************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : Show status of collector from systemd] ***********************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">changed: [testmachine3]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">TASK [chronocollector : debug] *******************************************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">ok: [testmachine3] =&gt; {<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\"> &#8220;status.stdout&#8221;: &#8221; Active: failed (Result: exit-code) since Thu 2022-05-19 10:31:49 BST; 315ms ago&#8221;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">}<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">PLAY RECAP ***************************************************************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #0070c0;\">testmachine3 : ok=15 changed=8 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/chronosphere.io\/ &#8211; Third Party Cloud Monitoring Solution Chronocollector: &#8211; https:\/\/github.com\/Perfect10NickTailor\/chronocollector This role deploys the chronocollector management service which sends the data to domain.chronosphere.io For those of you who don\u2019t know what it is. Its basically a cloud monitoring tool that scrapes data on your instances and then you can create dashboards or even export the data to promethus to make<a href=\"https:\/\/nicktailor.com\/tech-blog\/how-to-pass-an-api-key-with-ansible\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,135,138],"tags":[],"class_list":["post-1469","post","type-post","status-publish","format-standard","hentry","category-ansible","category-apis","category-linux"],"_links":{"self":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/comments?post=1469"}],"version-history":[{"count":13,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1469\/revisions"}],"predecessor-version":[{"id":1484,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1469\/revisions\/1484"}],"wp:attachment":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/media?parent=1469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/categories?post=1469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/tags?post=1469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}