Just enough Ansible for Drupal | Lakshmi Narasimhan

Views: 693

This looks like a good Ansible Playbook to install Drupal 7 or any version, both on nginx and Apache. https://lakshminp.com/just-enough-ansible-drupal



Back to our newly minted machine. Let’s ensure Ansible is able to communicate with our server. First, we need to create a configuration file for Ansible. This is called ansible.cfg and it’s in INI format. This provides Ansible with a set of sensible defaults to operate on. This exists globally, but we can configure it on a per project basis.

hostfile = hosts

The hostfile indicates the file which contains a set of machines on which our software needs to be provisioned. This is usually called the “inventory” in Ansible. In our case, the hosts file will be a plain text file which will contain the IP of the new DigitalOcean server we created.

The host_key_checking is a boolean which indicates whether we should check for the host key while doing an SSH. In other words, if you set this to false, you won’t get this kind of a prompt while running ansible.

The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:cVfgg3nMw6K3sT/fQaLBiysbigx8YblQ7xaB8EtgpHw.
Are you sure you want to continue connecting (yes/no)?

We don’t want any questions to prompt us and interfere with our automation, do we? There is one more caveat we should be aware of. Ansible expects a python interpreter to be available on the remote machine. All basic Linux setups have Python installed, which is the good part. The bad part is, Ansible expects this to be Python version 2.x. So, if the default Python version on the remote machine(s) is 3.x, Ansible bails out with this kind of an error. | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Shared connection to closed.\r\n", 
    "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", 
    "msg": "MODULE FAILURE"

We need to tell ansible to expect a Python 3 interpreter in all the hosts it hits. We do that by adding these lines in our hosts file.



Source: Just enough Ansible for Drupal | Lakshmi Narasimhan

Leave a Reply