# Softlayer machines come with SSH root access and no users set up. This doesn't
# match how OpenStack and other providers work so create a user with the right
# ssh key so we don't nee to modify our whole hoist repo to handle softlayer.
---
- hosts: all
  vars:
    softlayer_user: ubuntu
    softlayer_authorized_key: "{{ secrets.ssh_keys.cideploy.public | mandatory }}"
  tasks:
    - name: create a group
      group:
        name: "{{ softlayer_user }}"

    - name: create a user
      user:
        name: "{{ softlayer_user }}"
        group: "{{ softlayer_user }}"
        state: present

    - name: add cideploy authorized key
      authorized_key:
        user: "{{ softlayer_user }}"
        exclusive: yes
        key: "{{ softlayer_authorized_key }}"

# Softlayer machines come with SSH root access and no users set up. This doesn't
# match how OpenStack and other providers work so create a user with the right
# ssh key so we don't nee to modify our whole hoist repo to handle softlayer.
---
- hosts: all
  vars:
    softlayer_user: ubuntu
    softlayer_authorized_key: "{{ secrets.ssh_keys.cideploy.public | mandatory }}"
  tasks:
    - name: install sudo
      apt:
        name: "{{ item }}"
        state: present
      with_items:
        - sudo

    - name: create a group
      group:
        name: "{{ softlayer_user }}"

    - name: create a user
      user:
        name: "{{ softlayer_user }}"
        group: "{{ softlayer_user }}"
        state: present

    - name: add cideploy authorized key
      authorized_key:
        user: "{{ softlayer_user }}"
        exclusive: yes
        key: "{{ softlayer_authorized_key }}"

    - name: add sudo for user
      template:
        src: user-sudoers.j2
        dest: /etc/sudoers.d/softlayer
        mode: "0440"
        owner: root
        group: root
        validate: '/usr/sbin/visudo -cf %s'

Add sudo permissions to softlayer user
Add sudo permissions to softlayer user

Unfortunately if you don't give sudo to the cideploy user and then hoist
removes root login then we have no way to escalate ansible to actually
do things.

Make sure the user has sudo.

Signed-off-by: Jamie Lennox <1b9801e8e46f6bd96338b24e58c84c4f37762fc2@gmail.com>
