<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi William!<br></div><div><br></div><div>On Thu, 26 Aug 2021, at 10:22 PM, William McKee wrote:<br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div dir="ltr"><div class="qt-gmail_default" style="font-family:verdana, sans-serif;">1. I only have 1 server that I need to deploy sites onto. Don't expect this to change. Can I simplify the server setting along the following lines:<br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><div>```<br></div><div>all:<br></div><div>  hosts:<br></div><div>    '<a href="http://knowmad.com">knowmad.com</a>':<br></div><div>      ansible_ssh_host: 192.168.0.1<br></div><div>      ansible_ssh_user: dancer<br></div><div>```<br></div></div></div></div></blockquote><div><br></div><div>Oooh. I see. You are adding configs to your own server each time you add a new customer, rather than going and installing something on their server. I misunderstood that the first time around. :-) And yes, absolutely, you can totally have an inventory of a single host. <br></div><div><br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div dir="ltr"><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;">1a. What file do I put this information into? Does it belong in `./playbooks/onboard.yml`?<br></div></div></div></blockquote><div><br></div><div>It's in `inventory.yml` or `inventory.ini`, dependending on the format you're using.<br></div><div><br></div><div><br></div><div><br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div dir="ltr"><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;">1b. Since I'm not onboarding a server but rather using ansible to deploy a new site within a multi-tenant web app, I may rename that file to `./playbooks/deploy.yml`. Does that make sense? Or does this sound confusing?<br></div></div></div></blockquote><div><br></div><div><br></div><div>I'd say that "deploy" is maybe a tad generic. But hey, if it works for you, it works for you. Mostly if for the time being you have only one playbook. :-)  <br></div><div><br></div><div>And that goes for the roles as well. In my example I went Full-Metal Best Practices and created a role, with task files for the different subtasks. You could totally throw everything in a single playbook, considering how little there is to it. <br></div><div><br></div><div><br></div><div><br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div dir="ltr"><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;">2. For the site specific configurations, I already have a perl script that uses Template based config files to build the domain specific configuration files needed for a new site. Perhaps I could replace that with Ansible + jinja2 at a future date. I'd need to figure out how to pass in the domain specific info when deploying a new site.<br></div></div></div></blockquote><div><br></div><div>As a first pass you can use your perl script to create the config files and populate the `roles/*/files` directory. But if you have time, throw a quick glance at Jinja2. Honestly it's extremely close to Mustache / TT / Mason, so changing from one to the other is pretty painless (well, that's depending of how tortuous your templates are, I guess).<br></div><div><br></div><div><br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div dir="ltr"><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;">3. It appears that I'll need to build a new set of ansible tasks for each domain. Yes? Or, is there a way to define placeholders that can be passed into a task via the ansible command line?<br></div></div></div></blockquote><div><br></div><div>Yup. You can override/define variables from the command line, and you can pass variables to roles.<br></div><div><br></div><div><br></div><div>- name; do the thing, for sitename <br></div><div>  include_tasks: ./do_the_thing.yml<br></div><div>  vars:<br></div><div>    sitename: '{{ weird_env_variable }}'<br></div><div><br></div><div><br></div><div><br></div><div>And on the command line<br></div><div><br></div><div>$ ansible-playbook -e weird_env_variable=potato .... <br></div><div><br></div><div>(of course you could also have done `ansible-playbook -e sitename=potato ....` directly and skip the var mapping<br></div><div>in the task)<br></div><div><br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div dir="ltr"><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;">4. Do I run the ansible client on my workstation and let it connect to the server? Do I need to install any ansible components on the server or only on my workstation? or both?<br></div></div></div></blockquote><div><br></div><div>You run Ansible from your workstation. All that the remote hosts need is ssh enabled and Python.<br></div><div><br></div><div><br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div dir="ltr"><div class="qt-gmail_default" style="font-family:verdana, sans-serif;"><br></div><div class="qt-gmail_default" style="font-family:verdana, sans-serif;">5. In addition to the site-specific files, I also need to push up any edits to the Perl libs, etc. I'm currently using rsync to do so. Wondering if I may be better off using ansible to manage the entire deployment process to the server.<br></div></div></div></blockquote><div><br></div><div>In addition of calling the shell commands yourself, there are a few Perl-centric modules for Ansible. Like <a href="https://docs.ansible.com/ansible/latest/collections/community/general/cpanm_module.html">https://docs.ansible.com/ansible/latest/collections/community/general/cpanm_module.html</a> (that one is core) and <a href="https://github.com/swfz/ansible-plenv">https://github.com/swfz/ansible-plenv</a> (that one is part of the community set of roles)<br></div><div><br></div><div><br></div><div>Joy,<br></div><div>`/anick<br></div><div><br></div></body></html>