---
  - name: Test connection
    ping:

  - name: Set MOTD
    template:
      src: motd
      dest: /etc/motd
    sudo: true

  - name: Set hostname
    command: hostname {{hostname}}
    sudo: true

  - name: update /etc/hostname
    copy:
      content: "{{hostname}}"
      dest: /etc/hostname

  - name: Set hostname for systemd
    hostname:
      name: "{{hostname}}"

  - name: apt-get update
    apt: update_cache=yes cache_valid_time=86400
    sudo: true

  - name: apt-get upgrade
    apt: upgrade=full
    sudo: true

  - name: Set timezone variables
    copy: content='America/Chicago'
          dest=/etc/timezone
          owner=root
          group=root
          mode=0644
          backup=yes
    sudo: true
    notify:
      - update timezone

  - name: Add deploy user
    user:
      name: "{{deploy_user}}"
      state: present
      generate_ssh_key: yes
      shell: /bin/bash
    sudo: true

  - name: Update authorized_keys for deploy user
    copy:
      src: authorized_keys
      dest: "/home/{{deploy_user}}/.ssh/authorized_keys"
      owner: "{{deploy_user}}"
    sudo: true

  - name: Create directory to which to deploy
    file:
      path: /u/apps/{{project_name}}
      owner: "{{deploy_user}}"
      state: directory
    sudo: true

  - include: swap.yml

---
  - name: Test connection
    ping:

  - name: Set MOTD
    template:
      src: motd
      dest: /etc/motd
    sudo: true

  - name: Set hostname
    command: hostname {{hostname}}
    sudo: true

  - name: update /etc/hostname
    copy:
      content: "{{hostname}}"
      dest: /etc/hostname

  - name: Set hostname for systemd
    hostname:
      name: "{{hostname}}"

  - name: apt-get update
    apt: update_cache=yes cache_valid_time=86400
    sudo: true

  - name: apt-get upgrade
    apt: upgrade=full
    sudo: true

  - name: Set timezone variables
    copy: content='America/Chicago'
          dest=/etc/timezone
          owner=root
          group=root
          mode=0644
          backup=yes
    sudo: true
    notify:
      - update timezone

  - name: Add deploy user
    user:
      name: "{{deploy_user}}"
      state: present
      generate_ssh_key: yes
      shell: /bin/bash
    sudo: true

  - name: Add deploy user to adm group so it can view logs in /var/log
    user:
      name: "{{deploy_user}}"
      append: yes
      groups: "adm"

  - name: Update authorized_keys for deploy user
    copy:
      src: authorized_keys
      dest: "/home/{{deploy_user}}/.ssh/authorized_keys"
      owner: "{{deploy_user}}"
    sudo: true

  - name: Create directory to which to deploy
    file:
      path: /u/apps/{{project_name}}
      owner: "{{deploy_user}}"
      state: directory
    sudo: true

  - include: swap.yml

Add deploy to adm group to it can view /var/log files
Add deploy to adm group to it can view /var/log files
