# Copyright 2016 Teppo Kurki <teppo.kurki@iki.fi>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: 'Install Python PIP'
  apt: >
    pkg=python-pip
    state=latest

- name: 'Install AWS CLI'
  pip: >
    name=awscli
    state=latest

- name: Set home directory of the user
  set_fact:
    home_dir: /home/{{ aws_cli_user }}
  when: "not \"{{ aws_cli_user }}\" == \"root\""

- name: Create the AWS config directory
  file: >
    path={{ home_dir }}/.aws
    state=directory
    owner={{ aws_cli_user }}
    group={{ aws_cli_user }}
    mode=0755

- name: Copy AWS config
  template: >
    src=aws_cli_config.j2
    dest={{ home_dir }}/.aws/config
    owner={{ aws_cli_user }}
    group={{ aws_cli_user }}
    mode=0644

# Copyright 2016 Teppo Kurki <teppo.kurki@iki.fi>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: 'Install Python PIP'
  apt: >
    pkg=python-pip
    state=latest

- name: 'Install AWS CLI'
  pip: >
    name=awscli
    state=latest

- name: Set home directory for regular user
  set_fact:
    home_dir: /home/{{ aws_cli_user }}
  when: not aws_cli_user == "root"

- name: Set home directory for root
  set_fact:
    home_dir: /root
  when: aws_cli_user == "root"

- name: Create the AWS config directory
  file: >
    path={{ home_dir }}/.aws
    state=directory
    owner={{ aws_cli_user }}
    group={{ aws_cli_user }}
    mode=0755

- name: Copy AWS config
  template: >
    src=aws_cli_config.j2
    dest={{ home_dir }}/.aws/config
    owner={{ aws_cli_user }}
    group={{ aws_cli_user }}
    mode=0600

Fix aws-cli role's home dir handling and access rights to ~/.aws/config
Fix aws-cli role's home dir handling and access rights to ~/.aws/config
