12.2. 月次レポートの取得
Ansible Automation Platform から月次レポートを取得して、使用状況メトリクスを収集し、消費量ベースの請求レポートを作成できます。Red Hat Enterprise Linux または OpenShift Container Platform で月次レポートを取得するには、次の手順を使用します。
12.2.1. Red Hat Enterprise Linux の月次レポートの取得 リンクのコピーリンクがクリップボードにコピーされました!
Red Hat Enterprise Linux で月次レポートを取得するには、次の手順を使用します。
手順
scp -r username@controller_host:$METRICS_UTILITY_SHIP_PATH/data/<YYYY>/<MM>/ /local/directory/を実行します。生成されたレポートが、指定した送信先パスに
CCSP-<YEAR>-<MONTH>.xlsxという名前で保存されます。
12.2.2. Ansible Automation Platform Operator から OpenShift Container Platform の月次レポートを取得する リンクのコピーリンクがクリップボードにコピーされました!
専用の Ansible Playbook を実行して、OpenShift Container Platform の永続ボリューム要求から直接、月次使用状況レポートを取得します。これにより、消費量ベースの正確な請求とコンプライアンスが確保されます。
手順
次の Playbook を使用して、OpenShift Container Platform 上の Ansible Automation Platform の月次消費レポートを取得します。
注記この Playbook を使用するには、マシンに
kubernetes.core.k8sコレクションがインストールされている必要があります。# Requires Ansible and Kubernetes.core collection - name: Copy directory from Kubernetes PVC to local machine hosts: "{{ host | default(omit) }}" vars: report_dir_path: "/mnt/metrics/reports/{{ year }}/{{ month }}/" data_files_dir_path: "/mnt/metrics/data/{{ year }}/{{ month }}/{{ day }}" tasks: - name: Create a temporary pod to access PVC data kubernetes.core.k8s: definition: apiVersion: v1 kind: Pod metadata: name: temp-pod namespace: "{{ namespace_name }}" spec: containers: - name: busybox image: busybox command: ["/bin/sh"] args: ["-c", "sleep 3600"] # Keeps the container alive for 1 hour volumeMounts: - name: "{{ pvc }}" mountPath: "/mnt/metrics" volumes: - name: "{{ pvc }}" persistentVolumeClaim: claimName: automationcontroller-metrics-utility restartPolicy: Never register: pod_creation - name: Wait for both initContainer and main container to be ready kubernetes.core.k8s_info: kind: Pod namespace: "{{ namespace_name }}" name: temp-pod register: pod_status until: > pod_status.resources[0].status.containerStatuses[0].ready retries: 30 delay: 10 - name: Create a tarball of the directory of the report in the container kubernetes.core.k8s_exec: namespace: "{{ namespace_name }}" pod: temp-pod container: busybox command: tar czf /tmp/metrics.tar.gz -C "{{ report_dir_path }}" . register: tarball_creation - name: Create a tarball of the directory of the data files in the container kubernetes.core.k8s_exec: namespace: "{{ namespace_name }}" pod: temp-pod container: busybox command: tar czf /tmp/data_files.tar.gz -C "{{ data_files_dir_path }}" . register: tarball_creation_files - name: Copy the report tarball from the container to the local machine kubernetes.core.k8s_cp: namespace: "{{ namespace_name }}" pod: temp-pod container: busybox state: from_pod remote_path: /tmp/metrics.tar.gz local_path: "{{ local_dir }}/metrics.tar.gz" when: tarball_creation is succeeded - name: Copy the data files tarball from the container to the local machine kubernetes.core.k8s_cp: namespace: "{{ namespace_name }}" pod: temp-pod container: busybox state: from_pod remote_path: /tmp/data_files.tar.gz local_path: "{{ local_dir }}/data_files.tar.gz" when: tarball_creation_files is succeeded - name: Ensure the local directory exists ansible.builtin.file: path: "{{ local_dir }}" state: directory mode: '0755' - name: Extract the report tarball on the local machine ansible.builtin.unarchive: src: "{{ local_dir }}/metrics.tar.gz" dest: "{{ local_dir }}" remote_src: true extra_opts: "--strip-components=1" when: tarball_creation is succeeded - name: Extract the data files tarball on the local machine ansible.builtin.unarchive: src: "{{ local_dir }}/data_files.tar.gz" dest: "{{ local_dir }}" remote_src: true extra_opts: "--strip-components=1" list_files: true register: unarchive_result when: tarball_creation_files is succeeded - name: Extract the extracted data files tarball on the local machine ansible.builtin.unarchive: src: "{{ local_dir }}/{{ item }}" dest: "{{ local_dir }}" remote_src: true extra_opts: "--strip-components=1" loop: "{{ unarchive_result.files }}" when: tarball_creation_files is succeeded ignore_errors: true # noqa ignore-errors - name: Delete the temporary pod kubernetes.core.k8s: api_version: v1 kind: Pod namespace: "{{ namespace_name }}" name: temp-pod state: absent