File tree 18 files changed +73
-57
lines changed
18 files changed +73
-57
lines changed Original file line number Diff line number Diff line change 23
23
python-version : ' 3.x'
24
24
25
25
- name : Install test dependencies
26
- run : pip install ansible-lint[community,yamllint]
26
+ run : |
27
+ pip install ansible-lint
28
+ ansible-galaxy install -r requirements.yml
27
29
28
30
- name : Lint code
29
31
run : |
43
45
matrix :
44
46
include :
45
47
- distro : debian8
46
- ansible-version : ' <2.10'
47
48
- distro : debian9
48
49
- distro : debian10
49
- - distro : ubuntu1604
50
- ansible-version : ' >=2.9, <2.10'
51
50
- distro : ubuntu1604
52
51
ansible-version : ' >=2.10, <2.11'
53
52
- distro : ubuntu1604
Original file line number Diff line number Diff line change @@ -28,3 +28,5 @@ ansible.cfg
28
28
# Other files #
29
29
# ##############
30
30
! empty
31
+
32
+ files /id_rsa *
Original file line number Diff line number Diff line change 1
- FROM ubuntu:16 .04
1
+ FROM ubuntu:18 .04
2
2
MAINTAINER Mischa ter Smitten <
[email protected] >
3
3
4
+ ENV LANG C.UTF-8
5
+ ENV LC_ALL C.UTF-8
6
+
4
7
# python
5
8
RUN apt-get update && \
6
- DEBIAN_FRONTEND=noninteractive apt-get install -y python -minimal python -dev curl && \
9
+ DEBIAN_FRONTEND=noninteractive apt-get install -y python3 -minimal python3 -dev curl && \
7
10
apt-get clean
8
- RUN curl -sL https://bootstrap.pypa.io/pip/2.7 /get-pip.py | python -
11
+ RUN curl -sL https://bootstrap.pypa.io/pip/3.6 /get-pip.py | python3 -
9
12
RUN rm -rf $HOME/.cache
10
13
11
14
# ansible
12
- RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \
15
+ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-apt && \
13
16
apt-get clean
14
- RUN pip install ansible==2.9.15
17
+ RUN pip3 install ansible==2.10.7
15
18
RUN rm -rf $HOME/.cache
16
19
17
20
# provision
Original file line number Diff line number Diff line change 1
1
# meta file
2
2
---
3
3
galaxy_info :
4
- namespace : oefenweb
4
+ author : oefenweb
5
5
role_name : ssh_keys
6
- author : Mischa ter Smitten
7
6
company : Oefenweb.nl B.V.
8
7
description : Manage ssh public key authentication (public / private / authorized keys and known hosts) in Debian-like systems
9
8
license : MIT
10
- min_ansible_version : 2.9 .0
9
+ min_ansible_version : 2.10 .0
11
10
platforms :
12
11
- name : Ubuntu
13
12
versions :
Original file line number Diff line number Diff line change
1
+ ---
2
+ collections :
3
+ - name : community.docker
4
+ version : ' >=1.2.0,<2'
5
+ - name : community.general
6
+ version : ' >=2,<3'
Original file line number Diff line number Diff line change
1
+ # requirements file
2
+ ---
3
+ collections :
4
+ - name : ansible.posix
5
+ - name : community.crypto
Original file line number Diff line number Diff line change 1
1
# tasks file
2
2
---
3
3
- name : authorized-keys | set up for users
4
- authorized_key :
4
+ ansible.posix. authorized_key :
5
5
user : " {{ item.owner }}"
6
6
key : " {{ lookup('file', item.src) }}"
7
7
state : " {{ item.state | default('present') }}"
Original file line number Diff line number Diff line change 1
1
# tasks file
2
2
---
3
3
- name : general | create ssh directory
4
- file :
4
+ ansible.builtin. file :
5
5
path : " {{ (item.dest_absolute | default('~' + item.owner + '/' + ssh_keys_sshdir + '/' + (item.dest | default(ssh_keys_private_key_filename)))) | dirname }}"
6
6
state : directory
7
7
owner : " {{ item.owner }}"
14
14
- ssh-keys-general-create-ssh-directories-private-keys
15
15
16
16
- name : general | create ssh directory
17
- file :
17
+ ansible.builtin. file :
18
18
path : " ~{{ item.owner }}/{{ ssh_keys_sshdir }}"
19
19
state : directory
20
20
owner : " {{ item.owner }}"
Original file line number Diff line number Diff line change 1
1
# tasks file
2
2
---
3
- - block :
3
+ - name : generate
4
+ block :
4
5
5
6
- name : generate | create ssh key generation directory
6
- file :
7
+ ansible.builtin. file :
7
8
path : " {{ item.path | dirname }}"
8
9
owner : " {{ item.owner }}"
9
10
group : " {{ item.group | default(item.owner) }}"
14
15
- ssh-keys-generate-directories
15
16
16
17
- name : generate | generate private ssh key
17
- shell : " {{ ssh_keys_generate_keys_command | default(_ssh_keys_generate_keys_command) }}"
18
- tags :
19
- - ssh-keys-generate-private-keys
20
- - skip_ansible_lint
18
+ ansible.builtin.shell : >
19
+ {{ ssh_keys_generate_keys_command | default(_ssh_keys_generate_keys_command) }}
20
+ with_items : " {{ ssh_keys_generate_keys }}"
21
21
when : >-
22
22
item.force | default(false) | bool or
23
23
item.path is not file
24
- with_items : " {{ ssh_keys_generate_keys }}"
24
+ tags :
25
+ - ssh-keys-generate-private-keys
26
+ - skip_ansible_lint
25
27
26
28
- name : generate | set permissions on keys
27
- file :
29
+ ansible.builtin. file :
28
30
path : " {{ item.path }}"
29
31
owner : " {{ item.owner }}"
30
32
group : " {{ item.group | default(item.owner) }}"
34
36
- ssh-keys-generate-permissions
35
37
36
38
- name : generate | generate public ssh key
37
- openssl_publickey :
39
+ community.crypto. openssl_publickey :
38
40
path : " {{ item.path }}.pub"
39
41
force : " {{ item.force | default(false) }}"
40
42
format : " {{ item.format | default('OpenSSH') }}"
Original file line number Diff line number Diff line change 1
1
# tasks file
2
2
---
3
3
- name : known-hosts | stat directories
4
- stat :
4
+ ansible.builtin. stat :
5
5
path : " {{ item }}/"
6
6
register : _stat_directories
7
7
with_items :
11
11
- ssh-keys-known-hosts-directories-stat
12
12
13
13
- name : known-hosts | create directories
14
- file :
14
+ ansible.builtin. file :
15
15
path : " {{ item.item }}"
16
16
state : directory
17
17
owner : root
24
24
- ssh-keys-known-hosts-directories-create
25
25
26
26
- name : known-hosts | update file
27
- template :
27
+ ansible.builtin. template :
28
28
src : " {{ ssh_keys_known_hosts_path.lstrip('/') }}.j2"
29
29
dest : " {{ ssh_keys_known_hosts_path }}"
30
30
owner : root
Original file line number Diff line number Diff line change 1
1
# tasks file
2
2
---
3
-
4
- - import_tasks : generate.yml
3
+ - ansible.builtin.import_tasks : generate.yml
5
4
tags :
6
5
- configuration
7
6
- ssh-keys
8
7
- ssh-keys-generate
9
8
10
- - import_tasks : general.yml
9
+ - ansible.builtin. import_tasks : general.yml
11
10
tags :
12
11
- configuration
13
12
- ssh-keys
14
13
- ssh-keys-general
15
14
16
- - import_tasks : private-keys.yml
15
+ - ansible.builtin. import_tasks : private-keys.yml
17
16
tags :
18
17
- configuration
19
18
- ssh-keys
20
19
- ssh-keys-private-keys
21
20
22
- - import_tasks : public-keys.yml
21
+ - ansible.builtin. import_tasks : public-keys.yml
23
22
tags :
24
23
- configuration
25
24
- ssh-keys
26
25
- ssh-keys-public-keys
27
26
28
- - import_tasks : authorized-keys.yml
27
+ - ansible.builtin. import_tasks : authorized-keys.yml
29
28
tags :
30
29
- configuration
31
30
- ssh-keys
32
31
- ssh-keys-authorized-keys
33
32
34
- - import_tasks : known-hosts.yml
33
+ - ansible.builtin. import_tasks : known-hosts.yml
35
34
tags :
36
35
- configuration
37
36
- ssh-keys
Original file line number Diff line number Diff line change 1
1
# tasks file
2
2
---
3
3
- name : private-keys | add
4
- copy :
4
+ ansible.builtin. copy :
5
5
src : " {{ item.src }}"
6
6
dest : " {{ item.dest_absolute | default('~' + item.owner + '/' + ssh_keys_sshdir + '/' + (item.dest | default(ssh_keys_private_key_filename))) }}"
7
7
owner : " {{ item.owner }}"
13
13
- ssh-keys-private-keys-add
14
14
15
15
- name : private-keys | remove
16
- file :
16
+ ansible.builtin. file :
17
17
path : " {{ item.dest_absolute | default('~' + item.owner + '/' + ssh_keys_sshdir + '/' + (item.dest | default(ssh_keys_private_key_filename))) }}"
18
18
state : absent
19
19
with_items : " {{ ssh_keys_private_keys }}"
Original file line number Diff line number Diff line change 1
1
# tasks file
2
2
---
3
3
- name : public-keys | add
4
- copy :
4
+ ansible.builtin. copy :
5
5
src : " {{ item.src }}"
6
6
dest : " {{ item.dest_absolute | default('~' + item.owner + '/' + ssh_keys_sshdir + '/' + (item.dest | default(ssh_keys_public_key_filename))) }}"
7
7
owner : " {{ item.owner }}"
13
13
- ssh-keys-public-keys-add
14
14
15
15
- name : public-keys | remove
16
- file :
16
+ ansible.builtin. file :
17
17
path : " {{ item.dest_absolute | default('~' + item.owner + '/' + ssh_keys_sshdir + '/' + (item.dest | default(ssh_keys_public_key_filename))) }}"
18
18
state : absent
19
19
with_items : " {{ ssh_keys_public_keys }}"
Original file line number Diff line number Diff line change 1
1
# post test file
2
2
---
3
3
- name : set fact
4
- command : >
4
+ ansible.builtin. command : >
5
5
echo "{{ ansible_connection }}"
6
6
register : _ansible_connection
7
7
changed_when : false
8
8
9
9
- block :
10
10
11
11
- name : test presence of private key
12
- shell : >
13
- diff {{ ssh_keys_private_keys[0]['src'] }} ~dummy /.ssh/{{ ssh_keys_private_keys[0]['src'] | basename }}
12
+ ansible.builtin. shell : >
13
+ diff {{ ssh_keys_private_keys[0]['src'] }} ~{{ ssh_keys_owner }} /.ssh/{{ ssh_keys_private_keys[0]['src'] | basename }}
14
14
&& (echo 'Private key test: pass' && exit 0)
15
15
|| (echo 'Private key test: fail' && exit 1)
16
16
args :
20
20
- skip_ansible_lint
21
21
22
22
- name : test presence of public key
23
- shell : >
24
- diff {{ ssh_keys_public_keys[0]['src'] }} ~dummy /.ssh/{{ ssh_keys_public_keys[0]['src'] | basename }}
23
+ ansible.builtin. shell : >
24
+ diff {{ ssh_keys_public_keys[0]['src'] }} ~{{ ssh_keys_owner }} /.ssh/{{ ssh_keys_public_keys[0]['src'] | basename }}
25
25
&& (echo 'Public key test: pass' && exit 0)
26
26
|| (echo 'Public key test: fail' && exit 1)
27
27
args :
33
33
- skip_ansible_lint
34
34
35
35
- name : test presence of known hosts
36
- shell : >
36
+ ansible.builtin. shell : >
37
37
grep -q 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa' /etc/ssh/ssh_known_hosts
38
38
&& (echo 'Known hosts test: pass' && exit 0)
39
39
|| (echo 'Known hosts test: fail' && exit 1)
Original file line number Diff line number Diff line change 1
1
# pre test file
2
2
---
3
3
- name : install dependencies
4
- apt :
4
+ ansible.builtin. apt :
5
5
name :
6
6
- openssh-client
7
7
state : " {{ apt_install_state | default('latest') }}"
8
8
update_cache : true
9
9
cache_valid_time : " {{ apt_update_cache_valid_time | default(3600) }}"
10
10
11
11
- name : generate key pair
12
- command : >
12
+ ansible.builtin. command : >
13
13
ssh-keygen -t rsa -b 2048 -C '' -P '' -f {{ ssh_keys_private_key }} -q
14
14
args :
15
15
creates : " {{ ssh_keys_private_key }}"
16
16
connection : local
17
17
become : false
18
18
19
19
- name : create user (if needed)
20
- user :
21
- name : dummy
20
+ ansible.builtin. user :
21
+ name : " {{ ssh_keys_owner }} "
Original file line number Diff line number Diff line change 5
5
become : true
6
6
pre_tasks :
7
7
- name : include vars
8
- include_vars : " {{ playbook_dir }}/vars/main.yml"
8
+ ansible.builtin. include_vars : " {{ playbook_dir }}/vars/main.yml"
9
9
- name : include tasks
10
- include : " {{ playbook_dir }}/tasks/pre.yml"
10
+ ansible.builtin. include : " {{ playbook_dir }}/tasks/pre.yml"
11
11
roles :
12
12
- ../../
13
13
post_tasks :
14
14
- name : include tasks
15
- include : " {{ playbook_dir }}/tasks/post.yml"
15
+ ansible.builtin. include : " {{ playbook_dir }}/tasks/post.yml"
Original file line number Diff line number Diff line change 5
5
become : true
6
6
pre_tasks :
7
7
- name : include vars
8
- include_vars : " {{ playbook_dir }}/vars/main.yml"
8
+ ansible.builtin. include_vars : " {{ playbook_dir }}/vars/main.yml"
9
9
- name : include tasks
10
- include : " {{ playbook_dir }}/tasks/pre.yml"
10
+ ansible.builtin. include : " {{ playbook_dir }}/tasks/pre.yml"
11
11
roles :
12
12
- ../../
13
13
post_tasks :
14
14
- name : include tasks
15
- include : " {{ playbook_dir }}/tasks/post.yml"
15
+ ansible.builtin. include : " {{ playbook_dir }}/tasks/post.yml"
Original file line number Diff line number Diff line change 1
1
# vars file
2
2
---
3
+ ssh_keys_owner : dummy
3
4
ssh_keys_private_keys :
4
- - owner : dummy
5
+ - owner : " {{ ssh_keys_owner }} "
5
6
src : " {{ ssh_keys_private_key }}"
6
7
ssh_keys_public_keys :
7
- - owner : dummy
8
+ - owner : " {{ ssh_keys_owner }} "
8
9
src : " {{ ssh_keys_private_key }}.pub"
9
10
ssh_keys_authorized_keys :
10
- - owner : dummy
11
+ - owner : " {{ ssh_keys_owner }} "
11
12
src : " {{ ssh_keys_private_key }}.pub"
12
13
ssh_keys_known_hosts :
13
14
- hostname : github.com
You can’t perform that action at this time.
0 commit comments