|
| 1 | +# Ansible SnapMirror Report |
| 2 | +This Ansible playbook generates a report of all the FSx for ONTAP SnapMirror relationships within an AWS account. |
| 3 | +The output of the report is a CSV file with the following columns: |
| 4 | +- File System ID |
| 5 | +- Source Path (svm:volume) |
| 6 | +- Destination Path (svm:volume) |
| 7 | +- State (e.g. snapmirrored, broken-off) |
| 8 | +- Healthy (true or false) |
| 9 | +- lag\_time (in "P#DT#H#M#S" format. See below for an explanation) |
| 10 | + |
| 11 | +The lag\_time format is an ASCII string that always starts with the letter 'P' and if the lag time is more than 24 hours it is followed by |
| 12 | +a number and the letter 'D'. The number represents the number days. The next character is always a 'T' and is followed by |
| 13 | +number/letter pairs, where the letter is either an 'H', 'M', or 'S'. If the letter is 'H' then the number before it represents |
| 14 | +the number of hours. If the letter is 'M' then the number before it represents the number of minutes. If the letter is 'S' then |
| 15 | +the number before it represents the number of seconds. For example, 'P1DT2H3M4S' represents 1 day, 2 hours, 3 minutes, and 4 seconds. |
| 16 | + |
| 17 | +## Requirements |
| 18 | +- jq - A lightweight and flexible command-line JSON processor. Installation instructions can be found [here](https://jqlang.github.io/jq/download/) |
| 19 | +- Ansible 2.9 or later. Installation instructions can be found [here](https://docs.ansible.com/ansible/latest/installation_guide/index.html) |
| 20 | +- AWS Ansible collection. This should be included with the base installation of Ansible. |
| 21 | +- AWS secret(s) with the credentials necessary to run SnapMirror ONTAP APIs against the FSx for ONTAP file systems. The required format of the secret is described below. |
| 22 | + |
| 23 | +## Installation |
| 24 | +There are three files used to create the report: |
| 25 | +- `generate_report.yaml`: The Ansible playbook that generates the report. |
| 26 | +- `processs_region.yaml`: A collection of tasks that will process all the FSxNs in a region. |
| 27 | +- `get_all_fsxn_regions.yaml`: A collection of tasks that retrieves all the regions, that are enabled for the account, where FSx for ONTAP is available. |
| 28 | + |
| 29 | +You will also need to create a file named (by default) `secrets_list.csv` that list the secret name for each FSx file systems. |
| 30 | +The format of the file should be: |
| 31 | +``` |
| 32 | +file_system_id,secret_name |
| 33 | +``` |
| 34 | +:warning: **NOTE:** Do not add any spaces before or after the file\_system\_id or secret\_name. |
| 35 | + |
| 36 | +Each secret should have two `keys`: |
| 37 | +| Key | Value | |
| 38 | +| --- | --- | |
| 39 | +| `username` | The username to use to authenticate with the FSx for ONTAP file system. | |
| 40 | +| `password` | The password to use to authenticate with the FSx for ONTAP file system. | |
| 41 | + |
| 42 | +## Configuration |
| 43 | +There are a few variables that can be changed at the top of the `generate_report.yaml` file: |
| 44 | +- report\_name - Sets the file path of the report that will be generated. |
| 45 | +- secrets\_list\_file - Sets the file path of the file that contains the list of FSx file systems and their secrets. See above for more information. |
| 46 | +- secrets\_region - Set the region where the secrets are stored. |
| 47 | + |
| 48 | +Since this script leverages the AWS Ansible collection as well as the `aws` cli, you will need to provide authentication credentials for them. |
| 49 | +You can read more about how to do that [here](https://docs.ansible.com/ansible/latest/collections/amazon/aws/docsite/aws_ec2_guide.html#authentication). |
| 50 | + |
| 51 | +## Usage |
| 52 | +To generate the report, run the following command: |
| 53 | +```bash |
| 54 | +ansible-playbook generate_report.yaml |
| 55 | +``` |
| 56 | +After a successful run, the report will be stored in the file specified by the `report_name` variable. |
| 57 | + |
| 58 | +## Author Information |
| 59 | + |
| 60 | +This repository is maintained by the contributors listed on [GitHub](https://github.com/NetApp/FSx-ONTAP-samples-scripts/graphs/contributors). |
| 61 | + |
| 62 | +## License |
| 63 | + |
| 64 | +Licensed under the Apache License, Version 2.0 (the "License"). |
| 65 | + |
| 66 | +You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0). |
| 67 | + |
| 68 | +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an _"AS IS"_ basis, without WARRANTIES or conditions of any kind, either express or implied. |
| 69 | + |
| 70 | +See the License for the specific language governing permissions and limitations under the License. |
| 71 | + |
| 72 | +© 2024 NetApp, Inc. All Rights Reserved. |
0 commit comments