Skip to content

Instantly share code, notes, and snippets.

@ksylvan
Created August 4, 2017 17:58
Show Gist options
  • Save ksylvan/f03d5dbbc956b8f6460b7c66cd402a5f to your computer and use it in GitHub Desktop.
Save ksylvan/f03d5dbbc956b8f6460b7c66cd402a5f to your computer and use it in GitHub Desktop.
Nice idempotence checking by Ansible. The first playbook is `bootstrap.yml` and the second is `mailserver.yml`
kayvan@thor mail-server:(master)$ make redo
ansible-playbook -u deploy bootstrap.yml
PLAY [all] ********************************************************************************************
TASK [Install python 2 if not there] ******************************************************************
ok: [netconnect.net]
TASK [Install sudo if not there] **********************************************************************
ok: [netconnect.net]
TASK [Add deploy user] ********************************************************************************
ok: [netconnect.net]
TASK [Add authorized keys for deploy user] ************************************************************
ok: [netconnect.net] => (item=~/.ssh/id_rsa.pub)
TASK [Add deploy user to sudoers] *********************************************************************
ok: [netconnect.net]
PLAY [all] ********************************************************************************************
TASK [Gathering Facts] ********************************************************************************
ok: [netconnect.net]
TASK [command] ****************************************************************************************
ok: [netconnect.net]
TASK [Set hostname] ***********************************************************************************
skipping: [netconnect.net]
TASK [hostname] ***************************************************************************************
skipping: [netconnect.net]
TASK [Fix /etc/hosts] *********************************************************************************
ok: [netconnect.net]
TASK [apt] ********************************************************************************************
ok: [netconnect.net]
TASK [Update APT Package cache] ***********************************************************************
ok: [netconnect.net]
TASK [Upgrade APT to the latest packages] *************************************************************
ok: [netconnect.net]
TASK [Install required packages] **********************************************************************
ok: [netconnect.net] => (item=[u'ufw', u'fail2ban', u'unattended-upgrades', u'ssmtp', u'logwatch'])
TASK [Install optional packages] **********************************************************************
ok: [netconnect.net] => (item=[u'mosh', u'vim'])
TASK [Adjust APT update intervals] ********************************************************************
ok: [netconnect.net]
TASK [service] ****************************************************************************************
ok: [netconnect.net]
TASK [Allow ssh traffic] ******************************************************************************
ok: [netconnect.net]
TASK [Allow mosh traffic] *****************************************************************************
ok: [netconnect.net]
TASK [Setup ufw (with deny default now)] **************************************************************
ok: [netconnect.net]
TASK [Email log summary daily] ************************************************************************
ok: [netconnect.net]
TASK [Fix mailhub in ssmtp config] ********************************************************************
ok: [netconnect.net]
TASK [Change root password] ***************************************************************************
ok: [netconnect.net]
TASK [Change ssh port] ********************************************************************************
ok: [netconnect.net]
TASK [Disallow password authentication] ***************************************************************
ok: [netconnect.net]
TASK [Disallow root SSH access] ***********************************************************************
ok: [netconnect.net]
PLAY RECAP ********************************************************************************************
netconnect.net : ok=24 changed=0 unreachable=0 failed=0
echo "Running playbook using deploy user"; \
ansible-playbook -u deploy mailserver.yml
Running playbook using deploy user
PLAY [all] ********************************************************************************************
TASK [Gathering Facts] ********************************************************************************
ok: [netconnect.net]
TASK [docker : remove any old docker versions] ********************************************************
ok: [netconnect.net] => (item=[u'docker', u'docker-engine', u'docker.io'])
TASK [docker : allow apt to use a repository over HTTPS] **********************************************
ok: [netconnect.net] => (item=[u'apt-transport-https', u'ca-certificates', u'curl', u'gnupg2', u'software-properties-common'])
TASK [docker : See if Docker Official GPG key is already installed] ***********************************
ok: [netconnect.net]
TASK [docker : Add Docker official GPG key] ***********************************************************
skipping: [netconnect.net]
TASK [docker : Add docker repo] ***********************************************************************
ok: [netconnect.net]
TASK [docker : Install docker-ce] *********************************************************************
ok: [netconnect.net] => (item=[u'docker-ce', u'docker-compose'])
TASK [docker : docker group] **************************************************************************
ok: [netconnect.net]
TASK [docker : Add deploy user to docker group] *******************************************************
ok: [netconnect.net]
TASK [unblock-ports : unblock the needed ports] *******************************************************
ok: [netconnect.net] => (item=25)
ok: [netconnect.net] => (item=80)
ok: [netconnect.net] => (item=110)
ok: [netconnect.net] => (item=143)
ok: [netconnect.net] => (item=443)
ok: [netconnect.net] => (item=465)
ok: [netconnect.net] => (item=587)
ok: [netconnect.net] => (item=993)
ok: [netconnect.net] => (item=995)
ok: [netconnect.net] => (item=4190)
TASK [certificates : Set up the mount path] ***********************************************************
ok: [netconnect.net]
TASK [certificates : Generate certs] ******************************************************************
ok: [netconnect.net]
TASK [certificates : Install certbot] *****************************************************************
ok: [netconnect.net]
TASK [certificates : Renew script] ********************************************************************
ok: [netconnect.net]
TASK [certificates : Set up renewal cron job] *********************************************************
ok: [netconnect.net]
TASK [mailserver : purge Exim installation] ***********************************************************
ok: [netconnect.net] => (item=[u'exim4', u'exim4-base', u'exim4-config', u'exim4-daemon-light'])
TASK [mailserver : Copy over docker-compose.yml] ******************************************************
ok: [netconnect.net]
TASK [mailserver : New systemd unit to run docker-compose] ********************************************
ok: [netconnect.net]
TASK [mailserver : Enable mailserver.service] *********************************************************
ok: [netconnect.net]
TASK [mailserver : postfix config directory] **********************************************************
ok: [netconnect.net]
TASK [mailserver : postfix config override] ***********************************************************
ok: [netconnect.net]
TASK [mailserver : nginx sites directory] *************************************************************
ok: [netconnect.net]
TASK [mailserver : Enable sites] **********************************************************************
ok: [netconnect.net] => (item=postfixadmin)
ok: [netconnect.net] => (item=rainloop)
ok: [netconnect.net] => (item=contact)
TASK [mailserver : contact form config directory] *****************************************************
ok: [netconnect.net] => (item=config)
ok: [netconnect.net] => (item=ssmtp)
TASK [mailserver : contact config files] **************************************************************
ok: [netconnect.net] => (item=config/config.php)
ok: [netconnect.net] => (item=ssmtp/ssmtp.conf)
ok: [netconnect.net] => (item=index.php)
TASK [mailserver : rainloop plugin directory] *********************************************************
ok: [netconnect.net]
TASK [mailserver : copy postfixadmin password change plugin into rainloop] ****************************
ok: [netconnect.net]
PLAY RECAP ********************************************************************************************
netconnect.net : ok=26 changed=0 unreachable=0 failed=0
kayvan@thor mail-server:(master)$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment