summaryrefslogtreecommitdiffstats
path: root/ansible/host/autocluster_setup_ssh.yml
blob: 1f6cbc5d6d31529aec14bdb47d744bd00053fd8e (plain)
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
---
- name: Set up an autocluster SSH key for the current user
  connection: local
  hosts: localhost

  tasks:
  - name: create SSH autocluster ID
    # Not the most modern but compatibile with old distros such as
    # Centos 6
    command: >
      ssh-keygen -b 2028 -t rsa -N "" -C "autocluster"
        -f "{{ ansible_env.HOME }}/.ssh/id_autocluster"
    args:
      creates: "{{ ansible_env.HOME }}/.ssh/id_autocluster"

  - name: create SSH autocluster.d/ configuration directory
    file:
      path: "{{ ansible_env.HOME }}/.ssh/autocluster.d"
      state: directory

  - name: update SSH config to include config autocluster clusters
    lineinfile:
      path: "{{ ansible_env.HOME }}/.ssh/config"
      regexp: "^Include autocluster\.d/\*\.config$"
      line: "Include autocluster.d/*.config"