heat_template_version: rocky

description: >
  Install and Configure ReaR

parameters:
  ServiceData:
    default: {}
    description: Dictionary packing service data
    type: json
  ServiceNetMap:
    default: {}
    description: Mapping of service_name -> network name. Typically set
                 via parameter_defaults in the resource registry.  This
                 mapping overrides those in ServiceNetMapDefaults.
    type: json
  DefaultPasswords:
    default: {}
    type: json
  EndpointMap:
    default: {}
    description: Mapping of service endpoint -> protocol. Typically set
                 via parameter_defaults in the resource registry.
    type: json
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json
  BackupAndRestoreNFSServer:
    default: '192.168.24.1'
    description: The URL of NFS server to connect to
    type: string
    tags:
      - role_specific
  BackupAndRestoreNFSStorageFolder:
    default: '/ctl_plane_backups'
    description: NFS storage folder
    type: string
    tags:
      - role_specific
  BackupAndRestoreExcludePathsCommon:
    default: ['/data/*', '/tmp/*']
    description: Exclude paths commons list
    type: comma_delimited_list
    tags:
      - role_specific
  BackupAndRestoreRearSimulate:
    default: false
    description: Wether if rear is to run on simulation mode
    type: boolean
    tags:
      - role_specific
  BackupAndRestoreDebug:
    default: false
    description: Wether if rear is to run on debug mode
    type: boolean
    tags:
      - role_specific
  BackupAndRestoreHieraConfigFile:
    default: '/etc/puppet/hiera.yaml'
    description: Hiera configuration file path
    type: string
    tags:
      - role_specific
  BackupAndRestoreLocalConfig:
    default: {
      ISO_DEFAULT: '"automatic"',
      USING_UEFI_BOOTLOADER: 0,
      OUTPUT: 'ISO',
      BACKUP: 'NETFS',
      BACKUP_PROG_COMPRESS_OPTIONS: '( --gzip)',
      BACKUP_PROG_COMPRESS_SUFFIX: '".gz"'}
    description: Configuration that will be put into /etc/rear/local.conf
    type: json
    tags:
      - role_specific

outputs:
  role_data:
    description: Role data for ReaR
    value:
      service_name: rear
      host_prep_tasks:
        - include_role:
            name: backup-and-restore
            tasks_from: setup_rear
      ansible_group_vars:
        tripleo_backup_and_restore_nfs_server: {get_param: BackupAndRestoreNFSServer}
        tripleo_backup_and_restore_storage_folder: {get_param: BackupAndRestoreNFSStorageFolder}
        tripleo_backup_and_restore_exclude_paths_common:
          list_concat_unique:
            - {get_param: BackupAndRestoreExcludePathsCommon}
            -
              - str_replace:
                  template: 'folder/*'
                  params:
                    folder: {get_param: BackupAndRestoreNFSStorageFolder}
        tripleo_backup_and_restore_rear_simulate: {get_param: BackupAndRestoreRearSimulate}
        tripleo_backup_and_restore_debug: {get_param: BackupAndRestoreDebug}
        tripleo_backup_and_restore_local_config: {get_param: BackupAndRestoreLocalConfig}

