Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
backup_dest.yml 2.32 KiB
Newer Older
  • Learn to ignore specific revisions
  • freezed's avatar
    freezed committed
    ---
    - name: "BACKUP | USER | set user «{{ backup_user }}»"
      ansible.builtin.user:
        groups: backup
        name: "{{ backup_user }}"
        shell: "{{ user_shell }}"
        state: present
        uid: 1001
    
    - name: "BACKUP | USER | ssh dir presence for «{{ backup_user }}»"
      ansible.builtin.file:
        group: "{{ backup_user }}"
        mode: 0740
        owner: "{{ backup_user }}"
        path: "/home/{{ backup_user }}/.ssh/"
        state: directory
    
    - name: "BACKUP | USER | ssh config for «{{ backup_user }}»"
      ansible.builtin.template:
        dest: "/home/{{ backup_user }}/.ssh/config"
        group: "{{ backup_user }}"
        mode: 0640
        owner: "{{ backup_user }}"
        src: templates/ssh_config_backup.j2
    
    - name: BACKUP | ZFS | parent destination dataset
      when: inventory_hostname in groups.zfs
      community.general.zfs:
        name: zp0/bkp
        state: present
        extra_zfs_properties:
          mountpoint: none
          compression: lz4
    
    - name: "BACKUP | ZFS | allow commands for «{{ backup_user }}»"
      community.general.zfs_delegate_admin:
        name: zp0/bkp
        users: "{{ backup_user }}"
        permissions: receive,hold,release
    
    - name: BACKUP | ZFS | children destination datasets (production)
      when: inventory_hostname in groups.zfs
      loop: "{{ groups['production'] }}"
      community.general.zfs:
        name: "zp0/bkp/{{ hostvars[item]['inventory_hostname'] }}"
        state: present
        extra_zfs_properties:
          "autobackup:bkp_{{ hostvars[item]['inventory_hostname'] }}": true
          "autobackup:prod_policy": true
          mountpoint: "/home/{{ backup_user }}/repo/{{ hostvars[item]['inventory_hostname'] }}"
          sharenfs: "ro={{ hostvars[item]['ansible_host'] }}"
          "src:fqdn": "{{ hostvars[item]['inventory_fqdn' ]}}"
          "src:ip": "{{ hostvars[item]['ansible_host'] }}"
    
    - name: BACKUP | ZFS | children destination datasets (station)
      when: inventory_hostname in groups.zfs
      loop: "{{ groups['station'] }}"
      community.general.zfs:
        name: "zp0/bkp/{{hostvars[item]['inventory_hostname']}}"
        state: present
        extra_zfs_properties:
          "autobackup:bkp_{{ hostvars[item]['inventory_hostname'] }}": true
          "autobackup:stat_policy": true
          mountpoint: "/home/{{ backup_user }}/repo/{{ hostvars[item]['inventory_hostname'] }}"
          sharenfs: "ro={{ gateway }}"
          "src:fqdn": "{{ hostvars[item]['inventory_fqdn' ]}}"
          "src:ip": "{{ hostvars[item]['ansible_host'] }}"