|
|
1b2089 |
diff --git a/defaults/main.yml b/defaults/main.yml
|
|
|
1b2089 |
index 15a741d..270408c 100644
|
|
|
1b2089 |
--- a/defaults/main.yml
|
|
|
1b2089 |
+++ b/defaults/main.yml
|
|
|
1b2089 |
@@ -3,3 +3,6 @@ dump_target: null
|
|
|
1b2089 |
path: /var/crash
|
|
|
1b2089 |
core_collector: null
|
|
|
1b2089 |
system_action: reboot
|
|
|
1b2089 |
+ssh_dump_user: null
|
|
|
1b2089 |
+ssh_dump_server: null
|
|
|
1b2089 |
+sshkey: /root/.ssh/kdump_id_rsa
|
|
|
1b2089 |
diff --git a/tasks/main.yml b/tasks/main.yml
|
|
|
1b2089 |
index 2c95ced..427f83f 100644
|
|
|
1b2089 |
--- a/tasks/main.yml
|
|
|
1b2089 |
+++ b/tasks/main.yml
|
|
|
1b2089 |
@@ -8,6 +8,11 @@
|
|
|
1b2089 |
command: cat /sys/kernel/kexec_crash_size
|
|
|
1b2089 |
register: kexec_crash_size
|
|
|
1b2089 |
|
|
|
1b2089 |
+- include_tasks: ssh.yml
|
|
|
1b2089 |
+ when:
|
|
|
1b2089 |
+ - dump_target
|
|
|
1b2089 |
+ - dump_target.kind == "ssh"
|
|
|
1b2089 |
+
|
|
|
1b2089 |
- name: Generate /etc/kdump.conf
|
|
|
1b2089 |
template:
|
|
|
1b2089 |
src: kdump.conf.j2
|
|
|
1b2089 |
diff --git a/tasks/ssh.yml b/tasks/ssh.yml
|
|
|
1b2089 |
new file mode 100644
|
|
|
1b2089 |
index 0000000..2df84a8
|
|
|
1b2089 |
--- /dev/null
|
|
|
1b2089 |
+++ b/tasks/ssh.yml
|
|
|
1b2089 |
@@ -0,0 +1,17 @@
|
|
|
1b2089 |
+---
|
|
|
1b2089 |
+- stat: path="{{ sshkey }}"
|
|
|
1b2089 |
+ register: sshkey_stats
|
|
|
1b2089 |
+
|
|
|
1b2089 |
+- command: "/usr/bin/ssh-keygen -t rsa -f {{ sshkey }} -N '' "
|
|
|
1b2089 |
+ when: sshkey_stats.stat.exists == False
|
|
|
1b2089 |
+
|
|
|
1b2089 |
+- name: cat file to register
|
|
|
1b2089 |
+ shell: cat {{ sshkey }}.pub
|
|
|
1b2089 |
+ register: keydata
|
|
|
1b2089 |
+
|
|
|
1b2089 |
+- name:
|
|
|
1b2089 |
+ authorized_key:
|
|
|
1b2089 |
+ user: "{{ ssh_dump_user }}"
|
|
|
1b2089 |
+ key: "{{ keydata.stdout }}"
|
|
|
1b2089 |
+ state: present
|
|
|
1b2089 |
+ delegate_to: "{{ ssh_dump_server }}"
|
|
|
1b2089 |
diff --git a/templates/kdump.conf.j2 b/templates/kdump.conf.j2
|
|
|
1b2089 |
index 260e842..1b48ba3 100644
|
|
|
1b2089 |
--- a/templates/kdump.conf.j2
|
|
|
1b2089 |
+++ b/templates/kdump.conf.j2
|
|
|
1b2089 |
@@ -4,6 +4,11 @@
|
|
|
1b2089 |
{% if dump_target %}
|
|
|
1b2089 |
{{ dump_target.kind }} {{ dump_target.location }}
|
|
|
1b2089 |
{% endif %}
|
|
|
1b2089 |
+
|
|
|
1b2089 |
+{% if dump_target and dump_target.kind == "ssh" and sshkey != '/root/.ssh/kdump_id_rsa' %}
|
|
|
1b2089 |
+sshkey {{ sshkey }}
|
|
|
1b2089 |
+{% endif %}
|
|
|
1b2089 |
+
|
|
|
1b2089 |
path {{ path }}
|
|
|
1b2089 |
{% if core_collector %}
|
|
|
1b2089 |
core_collector {{ core_collector }}
|
|
|
1b2089 |
diff --git a/test/test_ssh.yml b/test/test_ssh.yml
|
|
|
1b2089 |
new file mode 100644
|
|
|
1b2089 |
index 0000000..af8b51e
|
|
|
1b2089 |
--- /dev/null
|
|
|
1b2089 |
+++ b/test/test_ssh.yml
|
|
|
1b2089 |
@@ -0,0 +1,32 @@
|
|
|
1b2089 |
+
|
|
|
1b2089 |
+- name: Ensure that the rule runs with ssh
|
|
|
1b2089 |
+ hosts: all
|
|
|
1b2089 |
+ vars:
|
|
|
1b2089 |
+ # this is the outside address under which the ssh dump server is
|
|
|
1b2089 |
+ # known and ansible is supposed to be configured to be able to
|
|
|
1b2089 |
+ # connect to it (via inventory).
|
|
|
1b2089 |
+ ssh_dump_server_outside: localhost
|
|
|
1b2089 |
+
|
|
|
1b2089 |
+ tasks:
|
|
|
1b2089 |
+ - name: gather facts from {{ ssh_dump_server_outside }}
|
|
|
1b2089 |
+ setup:
|
|
|
1b2089 |
+ delegate_to: "{{ ssh_dump_server_outside }}"
|
|
|
1b2089 |
+ delegate_facts: True
|
|
|
1b2089 |
+
|
|
|
1b2089 |
+ - include_role:
|
|
|
1b2089 |
+ name: kdump
|
|
|
1b2089 |
+ vars:
|
|
|
1b2089 |
+ ssh_dump_user: "{{ hostvars[ssh_dump_server_outside]['ansible_user_id'] }}"
|
|
|
1b2089 |
+ # This is the outside address. Ansible will connect to it to
|
|
|
1b2089 |
+ # copy the ssh key.
|
|
|
1b2089 |
+ ssh_dump_server: "{{ ssh_dump_server_outside }}"
|
|
|
1b2089 |
+ path: /tmp/test
|
|
|
1b2089 |
+ dump_target:
|
|
|
1b2089 |
+ kind: ssh
|
|
|
1b2089 |
+ # This is the ssh dump server address visible from inside
|
|
|
1b2089 |
+ # the machine being configured. Dumps are to be copied
|
|
|
1b2089 |
+ # there. We make here the assumption that this machine is
|
|
|
1b2089 |
+ # being run as a VM and the dump server is the VM host
|
|
|
1b2089 |
+ # (i.e. for ansible this is localhost). From the VM its
|
|
|
1b2089 |
+ # address is then identical to the default route.
|
|
|
1b2089 |
+ location: "{{ ssh_dump_user }}@{{ ansible_default_ipv4.gateway }}"
|