# Tasks for dumping a Redis backup from each host and pulling it to the # Backup Server. - name: Make sure Redis client is installed on the Target Hosts yum: name: redis state: installed - name: Remove any existing Redis backup directory file: path: "{{ backup_tmp_dir }}/redis" state: absent - name: Create a new Redis backup directory file: path: "{{ backup_tmp_dir }}/redis" state: directory - name: Get the Redis masterauth password shell: | /bin/hiera -c /etc/puppet/hiera.yaml redis::masterauth when: redis_masterauth_password is undefined register: redis_masterauth_password_cmd_output become: true no_log: true - name: Convert the Redis masterauth password if unknown set_fact: redis_masterauth_password: "{{ redis_masterauth_password_cmd_output.stdout_lines[0] }}" when: redis_masterauth_password is undefined no_log: true - name: Get the Redis VIP shell: | /bin/hiera -c /etc/puppet/hiera.yaml redis_vip when: redis_vip is undefined register: redis_vip_cmd_output become: true - name: Convert the Redis VIP if unknown set_fact: redis_vip: "{{ redis_vip_cmd_output.stdout_lines[0] }}" when: redis_vip is undefined - name: Run the redis backup command command: /bin/redis-cli -h {{ redis_vip }} -a {{ redis_masterauth_password }} save no_log: true - name: Copy the Redis dump copy: src: /var/lib/redis/dump.rdb dest: "{{ backup_tmp_dir }}/redis/dump.rdb" remote_src: yes become: true # The archive module is pretty limited. Using a shell instead. - name: Archive the OpenStack Redis dump shell: | /bin/tar --ignore-failed-read --xattrs \ -zcf {{ backup_tmp_dir }}/redis/openstack-backup-redis.tar \ {{ backup_tmp_dir }}/redis/dump.rdb - name: Copy the archive to the backup server synchronize: mode: pull src: "{{ backup_tmp_dir }}/redis/openstack-backup-redis.tar" dest: "{{ backup_directory }}" set_remote_user: false ssh_args: "{{ backup_host_ssh_args }}" delegate_to: "{{ backup_host }}" - name: Remove the Redis backup directory file: path: "{{ backup_tmp_dir }}/redis" state: absent