general improvements

This commit is contained in:
Luc Stroobant 2017-11-12 15:02:50 +01:00
parent a19708c9b5
commit b142349de7
5 changed files with 20 additions and 31 deletions

View file

@ -1,9 +1,9 @@
---
- name: client | generate ssh key for this machine
shell: if [ -f ~/.ssh/id_rsa ]; then rm -f ~/.ssh/id_rsa; fi && ssh-keygen -q -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" creates=~/.ssh/id_rsa.pub
shell: if [ -f {{ borgbackup_ssh_key }} ]; then rm -f {{ borgbackup_ssh_key }}; fi && ssh-keygen -q -t rsa -b 4096 -f {{ borgbackup_ssh_key }} -N "" creates="{{ borgbackup_ssh_key }}.pub"
- name: client | fetch ssh-key
shell: cat /root/.ssh/id_rsa.pub
shell: "cat {{ borgbackup_ssh_key }}.pub"
register: sshkey
changed_when: False
@ -14,12 +14,18 @@
line: 'export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"'
create: "yes"
- name: client | template sshconfig for backup-hosts (no strict key checking)
template:
src: "ssh.config.j2"
dest: "/root/.ssh/config"
owner: "root"
group: "root"
- name: client | disable strict key checking for backup servers
blockinfile:
dest: /root/.ssh/config
create: yes
marker: "### {mark} ANSIBLE MANAGED BLOCK {{ item.fqdn }} ###"
content: |
Host {{ item.fqdn }}
StrictHostKeyChecking no
{% if item.port is defined %}
Port {{ item.port }}
{% endif %}
with_items: "{{ borgbackup_servers }}"
- name: client | put sshpubkey on the normal backupserver
authorized_key:

View file

@ -1,16 +1,4 @@
---
- name: server | install borg backup
get_url:
dest: "/usr/local/bin/borg"
checksum: "{{ borgbackup_checksum }}"
owner: "root"
group: "root"
mode: "0755"
url: "{{ borgbackup_download_url }}"
delegate_to: "{{ item.fqdn }}"
with_items: "{{ borgbackup_servers }}"
when: item.type == 'normal'
- name: server | create user
user:
name: "{{ item.user }}"
@ -28,4 +16,5 @@
owner: "{{ item.user }}"
group: "{{ item.user }}"
mode: "0770"
delegate_to: "{{ item.fqdn }}"
with_items: "{{ borgbackup_servers }}"

View file

@ -10,7 +10,7 @@
- name: management | put management sshpubkey on the normal backupserver
authorized_key:
user: "{{ item.user }}"
key: "{{ borgbackup_management_sshkey }}"
key: "{{ borgbackup_management_ssh_pubkey }}"
delegate_to: "{{ item.fqdn }}"
when: item.type == 'normal'
with_items: "{{ borgbackup_servers }}"
@ -28,7 +28,7 @@
- name: management | modify local rsync.net authorized_keys
authorized_key:
user: "{{ ansible_user_id }}"
key: "{{ borgbackup_management_sshkey }}"
key: "{{ borgbackup_management_ssh_pubkey }}"
path: "/tmp/rsync.net-{{ item.fqdn }}-authkeys"
manage_dir: no
delegate_to: localhost