3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 - name: "create or delete chroot user"
18 name: "{{ item.name }}"
19 groups: "{{ item.group }}"
20 password: "{{ item.password | default('')}}"
21 remove: "{{ item.remove | default('yes')}}"
22 state: "{{ item.state | default('absent')}}"
26 with_items: "{{ chroot | default([]) }}"
28 - name: "Create the ssh-keys directory"
33 - name: "remove the old public ssh key"
35 path: /etc/ssh-keys/{{ item.name }}
37 with_items: "{{ chroot | default([]) }}"
39 - name: "add a new public ssh key"
40 when: item.state == 'present'
42 path: /etc/ssh-keys/{{ item.name }}
45 state: "{{ item.state | default('absent') }}"
46 line: "{{ item.public_key }}"
47 owner: "{{ item.name }}"
49 with_items: "{{ chroot | default([]) }}"
51 - name: Locking and Unlocking the user
52 when: item.state == 'present' and item.password != ""
53 command: sudo passwd "{{ item.name }}" "{{ item.lock_state }}"
54 with_items: "{{ chroot | default([]) }}"