#!/usr/bin/env bash
set -eux

### --start_docs

## Set up the non-root user for installation and deployment tasks
## ==============================================================


## * Create non-root user on undercloud
## ::

id -u "{{ undercloud_user }}" || \
sudo useradd -s /bin/bash -d /home/"{{ undercloud_user }}" "{{ undercloud_user }}"

## * Grant sudo privileges to non-root user on undercloud
## ::

echo "{{ undercloud_user }} ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/{{ undercloud_user }}
sudo chown root:root  /etc/sudoers.d/{{ undercloud_user }}
sudo chmod 440 /etc/sudoers.d/{{ undercloud_user }}

### --stop_docs
