Skip to content

Commit

Permalink
Merge pull request #35 from sansible/GITHUB-34-fix-home-dir-ssh
Browse files Browse the repository at this point in the history
[GITHUB-34] Fixes homedir ssh creation
  • Loading branch information
dennisconrad authored Feb 4, 2019
2 parents 6612c0e + 2c35e95 commit f74520c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ANSIBLE_INSTALL_VERSION ?= 2.2.3.0
ANSIBLE_INSTALL_VERSION ?= 2.7.6
PATH := $(PWD)/.venv_ansible$(ANSIBLE_INSTALL_VERSION)/bin:$(shell printenv PATH)
SHELL := env PATH=$(PATH) /bin/bash

Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies: []
galaxy_info:
description: Users and Groups Management Made Simple
license: MIT
min_ansible_version: 2.2
min_ansible_version: 2.5
platforms:
- name: Ubuntu
versions:
Expand Down
60 changes: 0 additions & 60 deletions molecule/default/create.yml

This file was deleted.

28 changes: 0 additions & 28 deletions molecule/default/destroy.yml

This file was deleted.

13 changes: 13 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
hosts: all

roles:
- role: users_and_groups
sansible_users_and_groups_groups:
- name: test_basic
sansible_users_and_groups_users:
- name: test_basic
group: test_basic
ssh_key: test_basic.pub
sansible_users_and_groups_sudoers:
- name: test_basic
user: "%test_basic"
runas: "ALL=(ALL)"
commands: "NOPASSWD: ALL"

- role: users_and_groups
sansible_users_and_groups_authorized_keys_dir: /etc/ssh/authorized_keys/

Expand Down
19 changes: 17 additions & 2 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,20 @@

- name: Prepare
hosts: all
gather_facts: false
tasks: []
gather_facts: no

tasks:
- name: Install Python for Ansible
become: yes
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream)
changed_when: no

- name: Install apt-transport-https, lsb-release, net-tools
become: yes
apt:
name: "{{ item }}"
update_cache: yes
with_items:
- apt-transport-https
- lsb-release
- net-tools
1 change: 1 addition & 0 deletions molecule/default/test_basic.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAA/gu0O2EI2lxAItjJzd/mN7sKtRWkpYg2HX/bnlfA01733kvTz1etqR6UqzQnyRK5mMGj5a6XQmezF2kyQztImkaDnnF0r5sz34QBhjIEy2MTw4eARprxLvN2voMQWMr8Rd7AgAkVQkXgAwsIZs0z1QA6dV4p8eDfNFVHYI9zScrCk41ljarLAge0vj9JfgIh0X6bz4hiG2+89QAXgICgpve6kXzA5BUQLyzn4E9H1MNFU/RVib5SgRldZyfCNP7qnRa+XUvNOj9WZslrVkwxViHgXKzz6xLoNGP0OrIA9FiZu5FaewP6xA59SPQyDFg6oCnvOxMgRyuGDH1cXiw7 [email protected]
9 changes: 9 additions & 0 deletions molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@


def test_groups(host):
assert host.group('test_basic').exists

assert host.group('test_one').exists

assert host.group('test_two').exists
Expand All @@ -17,6 +19,9 @@ def test_groups(host):


def test_users(host):
assert host.user('test_basic').exists
assert 'test_basic' in host.user('test_basic').groups

assert host.user('john').exists
assert 'test_one' in host.user('john').groups
assert 'test_two' in host.user('john').groups
Expand All @@ -33,6 +38,10 @@ def test_users(host):


def test_sudo(host):
with host.sudo('test_basic'):
with host.sudo():
assert host.check_output('whoami') == 'root'

with host.sudo('john'):
with host.sudo():
assert host.check_output('whoami') == 'root'
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
docker-py
molecule
docker==3.5.1
molecule==2.19.0
pytest==3.9.3
2 changes: 1 addition & 1 deletion tasks/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
- name: Create .ssh directory in default user home directory
become: yes
file:
path: "{{ item.home | default('/home/' ~ item.name)/}}/.ssh"
path: "{{ item.home | default('/home/' ~ item.name) }}/.ssh"
owner: "{{ item.name }}"
group: "{{ item.group | default(omit) }}"
mode: 0700
Expand Down

0 comments on commit f74520c

Please sign in to comment.