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 の永続ボリューム要求から直接、月次使用状況レポートを取得します。これにより、消費量ベースの正確な請求とコンプライアンスが確保されます。

手順

  1. 次の 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
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る