summaryrefslogtreecommitdiffstats
path: root/devel/fix_ssh.yml
blob: f2db45e9047bd2c20b121949f3ed8a2fb95f054f (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Create an authorized_keys file in the local directory containing the public keys for ssh access to the remote machine.
---
- hosts: all
  become: yes
  tasks:

    - name: Check if authorized_keys exist
      local_action: stat path=authorized_keys
      register: authorized_keys
      become: no

    - assert:
        that:
          - authorized_keys.stat.exists
        fail_msg: "authorized_keys does not exist. Please add an authorized_keys file which will be copied over to the test vms."
      run_once: true

    - name: Allow all users to sudo
      lineinfile:
        path: /etc/sudoers
        state: present
        insertafter: EOF
        line: 'ALL ALL=(ALL) NOPASSWD: ALL'

    - name: allow password authentication
      lineinfile:
        path: /etc/ssh/sshd_config
        state: present
        regexp: '^PasswordAuthentication no'
        line: 'PasswordAuthentication yes'

    - name: Restart sshd
      service:
        name: sshd
        state: restarted

    #Password: 'x'
    - name: change root password
      user:
        name: root
        update_password: always
        password: "$6$wEc5aSnByo3LM51M$TQzO2oyTmHzSncT/SGdVJAbCpuMOwfJSE2dS9p.L0gcFiG5./PqBREtDMdmxFZsuj1M5sq7iGoeoaKmt661Zh1"

    - name: Create /root/.ssh
      file:
        path: /root/.ssh
        owner: root
        group: root
        mode: 0700
        state: directory

    - name: Copy authorized_keys to /root/.ssh
      copy:
        src: authorized_keys
        dest: /root/.ssh/authorized_keys
        owner: root
        group: root
        mode: 0600

    - name: Install net-tools
      yum:
        name: net-tools
        state: present