File: test_key.yml

package info (click to toggle)
ansible-core 2.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 32,752 kB
  • sloc: python: 181,000; cs: 4,929; sh: 4,611; xml: 34; makefile: 21
file content (38 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
- ssh_keygen:
    type: "{{ item }}"
    passphrase: passphrase
  register: sshkey

- slurp:
    path: ~/.ssh/authorized_keys
  register: akeys

- copy:
    content: |
      {{ sshkey.public_key }}
      {{ akeys.content|b64decode }}
    dest: ~/.ssh/authorized_keys
    mode: '0400'

- block:
    - ping:

    - name: list keys from agent
      ssh_agent:
        action: list
      register: keys

    - assert:
        that:
          - keys.nkeys == ansible_loop.index
          - keys['keys'][ansible_loop.index0].fingerprint == fingerprint

    - name: key already exists in the agent
      ping:
  vars:
    ansible_password: ~
    ansible_ssh_password: ~
    ansible_ssh_private_key_file: ~
    ansible_ssh_private_key: '{{ sshkey.private_key }}'
    ansible_ssh_private_key_passphrase: passphrase
    fingerprint: '{{ sshkey.fingerprint }}'