Skip to content

Commit 21e8e67

Browse files
committed
Merge pull request #2 from Oefenweb/initial-version
Initial version
2 parents 198bfb5 + 80aac83 commit 21e8e67

File tree

19 files changed

+382
-0
lines changed

19 files changed

+382
-0
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# OS generated files #
2+
######################
3+
.DS_Store
4+
.DS_Store?
5+
._*
6+
.Spotlight-V100
7+
.Trashes
8+
Icon?
9+
ehthumbs.db
10+
Thumbs.db
11+
12+
# IDE files #
13+
#################
14+
/.settings
15+
/.buildpath
16+
/.project
17+
/nbproject
18+
*.komodoproject
19+
*.kpf
20+
/.idea
21+
22+
# Vagrant files #
23+
.vagrant/
24+
vagrant_ansible_inventory_*
25+
ansible.cfg
26+
27+
# Other files #
28+
###############
29+
!empty

.travis.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
language: python
3+
python: "2.7"
4+
5+
env:
6+
- ANSIBLE_VERSION=latest
7+
- ANSIBLE_VERSION=1.9.1
8+
- ANSIBLE_VERSION=1.9.0.1
9+
- ANSIBLE_VERSION=1.8.4
10+
- ANSIBLE_VERSION=1.8.3
11+
- ANSIBLE_VERSION=1.8.2
12+
- ANSIBLE_VERSION=1.8.1
13+
- ANSIBLE_VERSION=1.8
14+
- ANSIBLE_VERSION=1.7.2
15+
- ANSIBLE_VERSION=1.7.1
16+
- ANSIBLE_VERSION=1.7
17+
- ANSIBLE_VERSION=1.6.9
18+
- ANSIBLE_VERSION=1.6.8
19+
- ANSIBLE_VERSION=1.6.7
20+
- ANSIBLE_VERSION=1.6.6
21+
- ANSIBLE_VERSION=1.6.5
22+
- ANSIBLE_VERSION=1.6.4
23+
- ANSIBLE_VERSION=1.6.3
24+
- ANSIBLE_VERSION=1.6.2
25+
- ANSIBLE_VERSION=1.6.10
26+
- ANSIBLE_VERSION=1.6.1
27+
- ANSIBLE_VERSION=1.6
28+
- ANSIBLE_VERSION=1.5.5
29+
- ANSIBLE_VERSION=1.5.4
30+
- ANSIBLE_VERSION=1.5.3
31+
- ANSIBLE_VERSION=1.5.2
32+
- ANSIBLE_VERSION=1.5.1
33+
- ANSIBLE_VERSION=1.5
34+
- ANSIBLE_VERSION=1.4.5
35+
- ANSIBLE_VERSION=1.4.4
36+
- ANSIBLE_VERSION=1.4.3
37+
- ANSIBLE_VERSION=1.4.2
38+
- ANSIBLE_VERSION=1.4.1
39+
- ANSIBLE_VERSION=1.4
40+
41+
before_install:
42+
- sudo apt-get update -qq
43+
44+
install:
45+
# Install Ansible.
46+
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi
47+
48+
# Add ansible.cfg to pick up roles path.
49+
- printf "[defaults]\nroles_path = ../" > ansible.cfg
50+
51+
script:
52+
# Check the role/playbook's syntax.
53+
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check
54+
55+
# Run the role/playbook with ansible-playbook.
56+
- ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo -vvvv
57+
58+
# Run the role/playbook again, checking to make sure it's idempotent.
59+
- >
60+
ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo
61+
| grep -q 'changed=0.*failed=0'
62+
&& (echo 'Idempotence test: pass' && exit 0)
63+
|| (echo 'Idempotence test: fail' && exit 1)
64+
65+
notifications:
66+
email: false
67+
hipchat:
68+
rooms:
69+
secure: mEuqxFx3d1A6dRmhvjK3Ky5sm7I6zPnlIgHycwRsV1hSIid3I3aXcW7yMB8eu+y025OF1DYAB9R0rxUIwNxF96S6t3+121cE+a7D3ryX4rGNYzZg87kA4N/U3vclZip72Et31rGXAt5uYZ35Oy0ftMh8ojT/2xbjU3YatNtUlBdIw0nUhCxmeZZfOAmcb4Sh0XmGtEgfKRQLoGb01L70yXAdykvSmKjPoH0iwZ//cne24fRc9pCmY9cVQYZvYOLSeLBSXPrx4NqCv4PdDQeaec9fz6m0pJuVcJwUVXj+4dfG8QB64lqiwgTtBHf0JI/pcTabbPYblQa+tclQPpLV+hIMTpi3iEkNFTQxMwQDZ2x6YYW/2TV8vgF+cROlx+4FBJbzljAUw9XXylL/3FqaAcvpcwNkDo2AmyiFGHKsVZYz3Y8FG+4dBAWjCKK/dB4vwldgz6zxgXGVREDdfIUsyY5PSqhGtnW9JOaYylr9zfAJrBvEo/n0MoLTmI4bV8C7Om2G645NU/H/4/3u7GvfwCXPR7DqUfQ9Onz+2eWfHYm0qeBc+9hBzTNb2o5pnJVccc9jWsq4Fn6oL/OtRERw2BuVqqj5GiAlcO2s8fm29A92AFYkqbAVY0gLsxGi3OJ6629S1P9Rzw3rCddGd/dQqsNDvqRriE5XrtZlA/jzoVQ=

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
11
## ssh-keys
22

3+
[![Build Status](https://travis-ci.org/Oefenweb/ansible-ssh-keys.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-ssh-keys) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-ssh--keys-blue.svg)](https://galaxy.ansible.com/list#/roles/4176)
4+
5+
Manage ssh public key authentication (public / private / authorized keys and known hosts) in Debian-like systems.
6+
7+
#### Requirements
8+
9+
None
10+
11+
#### Variables
12+
13+
* `ssh_keys_users`: [default: `[]`]: User declarations
14+
* `ssh_keys_users.{n}.owner`: [required]: The name of the user that should own the file(s)
15+
* `ssh_keys_users.{n}.group`: [optional, default `owner`]: The name of the group that should own the file(s)
16+
* `ssh_keys_users.{n}.home`: [required]: The path of the home directory (of `owner`)
17+
* `ssh_keys_users.{n}.private_keys`: [default: `[]`]: Private keys declarations
18+
* `ssh_keys_users.{n}.private_keys.{n}.src`: [required]: The local path of the key
19+
* `ssh_keys_users.{n}.private_keys.{n}.dest`: [required]: The remote path of the key (relative to `home/.ssh/`)
20+
* `ssh_keys_users.{n}.private_keys.{n}.state`: [default: 'present']: State
21+
* `ssh_keys_users.{n}.public_keys`: [default: `[]`]: Public keys declarations
22+
* `ssh_keys_users.{n}.public_keys.{n}.src`: [required]: The local path of the key
23+
* `ssh_keys_users.{n}.public_keys.{n}.dest`: [required]: The remote path of the key (relative to `home/.ssh/`)
24+
* `ssh_keys_users.{n}.public_keys.{n}.state`: [default: `present`]: State
25+
* `ssh_keys_users.{n}.authorized_keys`: [default: `[]`]: Authorized keys declarations
26+
* `ssh_keys_users.{n}.authorized_keys.{n}.src`: [required]: The local path of the key
27+
* `ssh_keys_users.{n}.authorized_keys.{n}.state`: [default: `present`]: State
28+
29+
* `ssh_keys_known_hosts`: [default: `[]`]: Known hosts declarations
30+
* `ssh_keys_known_hosts.{n}.hostname`: [required]: The hostname
31+
* `ssh_keys_known_hosts.{n}.enctype`: [required]: The type of the fingerprint
32+
* `ssh_keys_known_hosts.{n}.fingerprint`: [required]: The actual fingerprint
33+
34+
## Dependencies
35+
36+
None
37+
38+
#### Example
39+
40+
```yaml
41+
---
42+
- hosts: all
43+
roles:
44+
- ssh-keys
45+
vars:
46+
ssh_keys_users:
47+
- owner: root
48+
home: /root
49+
private_keys:
50+
- src: ../../../files/ssh-keys/id_rsa
51+
dest: id_rsa
52+
state: present
53+
public_keys:
54+
- src: ../../../files/ssh-keys/id_rsa.pub
55+
dest: id_rsa.pub
56+
state: present
57+
authorized_keys:
58+
- src: ../../../files/ssh-keys/id_rsa.pub
59+
state: present
60+
ssh_keys_known_hosts:
61+
- hostname: github.com
62+
enctype: ssh-rsa
63+
fingerprint: 'AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
64+
```
65+
66+
The `fingerprint` and `enctype` can be obtained using `ssh-keyscan`: `ssh-keyscan github.com`.
67+
68+
#### License
69+
70+
MIT
71+
72+
#### Author Information
73+
74+
Mark van Driel
75+
Mischa ter Smitten
76+
77+
#### Feedback, bug-reports, requests, ...
78+
79+
Are [welcome](https://github.com/Oefenweb/ansible-ssh-keys/issues)!

Vagrantfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby ts=2 sw=2 tw=0 et :
3+
4+
role = File.basename(File.expand_path(File.dirname(__FILE__)))
5+
6+
File.open(File.dirname(__FILE__) + '/ansible.cfg', 'w') { |f| f.write("[defaults]\nroles_path = ../") }
7+
8+
boxes = [
9+
{
10+
:name => "ubuntu-1004",
11+
:box => "opscode-ubuntu-10.04",
12+
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-10.04_chef-provisionerless.box",
13+
:ip => '10.0.0.10',
14+
:cpu => "50",
15+
:ram => "256"
16+
},
17+
{
18+
:name => "ubuntu-1204",
19+
:box => "opscode-ubuntu-12.04",
20+
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box",
21+
:ip => '10.0.0.11',
22+
:cpu => "50",
23+
:ram => "256"
24+
},
25+
{
26+
:name => "ubuntu-1404",
27+
:box => "opscode-ubuntu-14.04",
28+
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box",
29+
:ip => '10.0.0.12',
30+
:cpu => "50",
31+
:ram => "256"
32+
},
33+
{
34+
:name => "debian-6010",
35+
:box => "opscode-debian-6.0.10",
36+
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-6.0.10_chef-provisionerless.box",
37+
:ip => '10.0.0.13',
38+
:cpu => "50",
39+
:ram => "256"
40+
},
41+
{
42+
:name => "debian-78",
43+
:box => "opscode-debian-7.8",
44+
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.8_chef-provisionerless.box",
45+
:ip => '10.0.0.14',
46+
:cpu => "50",
47+
:ram => "256"
48+
},
49+
]
50+
51+
Vagrant.configure("2") do |config|
52+
boxes.each do |box|
53+
config.vm.define box[:name] do |vms|
54+
vms.vm.box = box[:box]
55+
vms.vm.box_url = box[:url]
56+
vms.vm.hostname = "ansible-#{role}-#{box[:name]}"
57+
58+
vms.vm.provider "virtualbox" do |v|
59+
v.customize ["modifyvm", :id, "--cpuexecutioncap", box[:cpu]]
60+
v.customize ["modifyvm", :id, "--memory", box[:ram]]
61+
end
62+
63+
vms.vm.network :private_network, ip: box[:ip]
64+
65+
vms.vm.provision :ansible do |ansible|
66+
ansible.playbook = "tests/vagrant.yml"
67+
ansible.verbose = "vv"
68+
end
69+
end
70+
end
71+
end

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# defaults file for ssh-keys
2+
---
3+
ssh_keys_users: []
4+
5+
ssh_keys_known_hosts: []

files/empty

Whitespace-only changes.

handlers/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# handlers file for ssh-keys
2+
---

meta/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# meta file for ssh-keys
2+
---
3+
galaxy_info:
4+
author: Mischa ter Smitten
5+
company: Oefenweb.nl B.V.
6+
description: Manage ssh public key authentication (public / private / authorized keys and known hosts) in Debian-like systems
7+
license: MIT
8+
min_ansible_version: 1.4
9+
platforms:
10+
- name: Ubuntu
11+
versions:
12+
- lucid
13+
- precise
14+
- trusty
15+
- name: Debian
16+
versions:
17+
- squeeze
18+
- wheezy
19+
categories:
20+
- system
21+
- networking
22+
dependencies: []

tasks/authorized-keys.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# tasks file for ssh-keys
2+
---
3+
- name: set up authorized_keys for users
4+
authorized_key:
5+
user: "{{ item.0.owner }}"
6+
key: "{{ lookup('file', item.1.src) }}"
7+
state: "{{ item.1.state | default('present') }}"
8+
with_subelements:
9+
- ssh_keys_users
10+
- authorized_keys
11+
tags: [configuration, ssh-keys, ssh-keys-authorized-keys]

tasks/general.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# tasks file for ssh-keys
2+
---
3+
- name: create ssh directory
4+
file:
5+
path: "{{ item.home }}/{{ ssh_keys_sshdir }}"
6+
state: directory
7+
owner: "{{ item.owner }}"
8+
group: "{{ item.group | default(item.owner) }}"
9+
mode: 0700
10+
with_items: ssh_keys_users
11+
tags: [configuration, ssh-keys]

0 commit comments

Comments
 (0)