From cb2306889f762bd1cc2e5f5fc4c6402e648878c8 Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Fri, 18 Sep 2020 22:05:44 +0200 Subject: [PATCH] init --- .gitignore | 24 ++++ README.adoc | 61 +++++++++ defaults/main.yml | 2 + files/ssh-ca.rb | 328 ++++++++++++++++++++++++++++++++++++++++++++++ handlers/main.yml | 2 + meta/main.yml | 32 +++++ tasks/main.yml | 27 ++++ tests/inventory | 2 + tests/test.yml | 6 + vars/main.yml | 5 + 10 files changed, 489 insertions(+) create mode 100644 .gitignore create mode 100644 README.adoc create mode 100644 defaults/main.yml create mode 100755 files/ssh-ca.rb create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tests/inventory create mode 100644 tests/test.yml create mode 100644 vars/main.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fdcf9b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# ---> Vim +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +# ---> Ansible +*.retry + diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..93deb09 --- /dev/null +++ b/README.adoc @@ -0,0 +1,61 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +ssh_ca_name:: +Name for your CA - will be stored as comment. +If CA already exists, it will not be changed. +Mandatory. + +ssh_ca_user:: +User for CA. +Must match with `ssh_cert`-role. +Default: `sshca` + +ssh_ca_home:: +Default: `/var/lib/sshca` + +ssh_ca_base_dir:: +Where to store the certs and CA. +Must match with `ssh_cert`-role. +Default: `~/.ssh-ca` +**Do not change!** + +ssh_ca_force_regeneration:: +Forces to regenerate the CA. +*The old will be deleted!** + +Dependencies +------------ + +Use ssh-cert to use ssh-ca-server for re-/newal hosts and users certificates. + +Example Playbook +---------------- + +.example playbook +---- +- name: SSH-CA + hosts: ssh_ca_server + roles: + - role: ssh-ca +---- + +License +------- + +AGPLv3 + +Author Information +------------------ + +Denis Knauf - https://git.denkn.at/deac/ansible-role-ssh-cert diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..5746bf8 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for ssh-ca \ No newline at end of file diff --git a/files/ssh-ca.rb b/files/ssh-ca.rb new file mode 100755 index 0000000..b58317c --- /dev/null +++ b/files/ssh-ca.rb @@ -0,0 +1,328 @@ +#!/usr/bin/env ruby + +require 'time' +require 'pathname' +require 'shellwords' +require 'getoptlong' +require 'active_support/time' +require 'json' + +def help msg=nil + STDERR.puts msg if msg + STDERR.puts <<-EOHELP.gsub( /^\s*:/, '') + :Usage: ssh .... renew [force] [show] + : ssh .... show + : ssh .... help + : ssh .... jsonl + : + :[h]elp + :[r]enew Renews (if expires in graceperiod) or creates (if not existing) certificate + : [f]orce forces renewal, also if valid for graceperiod + :[s]how Shows current certificate + :jsonl Expect commands via STDIN as JSONL and responses via STDOUT in JSONL + : Request format: [0, CMD, ARGS...] + : Response format: [SCODE, BODY] + : SCODEs are like HTTP. + : + :possible CMD: + :}]> => + : => + : + : RENEWED indicates if file was renewed (true|false). + : CONTENT is the content of the certfile (String). + : DATA is the parsed file (ssh-keygen -L) (Hash). + EOHELP + exit 1 +end + +class Die