연습: CLI를 사용하여 인벤토리를 위한 관리형 노드 구성 - AWS Systems Manager

연습: CLI를 사용하여 인벤토리를 위한 관리형 노드 구성

다음 절차에서는 관리형 노드에서 메타데이터를 수집하도록 AWS Systems Manager 인벤토리를 구성하는 프로세스를 설명합니다. 인벤토리 수집을 구성할 때 Systems Manager State Manager 연결을 생성하는 것으로 시작합니다. Systems Manager는 연결이 실행될 때 인벤토리 데이터를 수집합니다. 연결을 먼저 생성하지 않고 Systems Manager Run Command 등을 사용하여 aws:softwareInventory 플러그인을 호출하려고 하면 시스템이 다음 오류를 반환합니다.

The aws:softwareInventory plugin can only be invoked via ssm-associate.

참고

노드에는 한 번에 하나의 인벤토리 연결만 구성할 수 있습니다. 둘 이상의 인벤토리 연결로 노드를 구성할 경우 연결이 실행되지 않으며 인벤토리 데이터가 수집되지 않습니다.

빠르게 인벤토리에 대한 모든 관리형 노드 구성(CLI)

AWS 계정 및 현재 리전의 모든 관리형 노드에서 인벤토리 데이터를 수집하도록 빠르게 구성할 수 있습니다. 이를 전역 인벤토리 연결 생성이라고 합니다. AWS CLI를 사용하여 전역 인벤토리 연결을 생성하려면 다음 절차에 나와 있듯이 instanceIds 값에 와일드카드 옵션을 사용하십시오.

AWS 계정 및 현재 리전의 모든 관리형 노드에서 인벤토리 구성(CLI)
  1. 아직 하지 않은 경우 AWS Command Line Interface(AWS CLI)를 설치하고 구성합니다.

    자세한 내용은 최신 버전의 AWS CLI 설치 또는 업데이트를 참조하세요.

  2. 다음 명령을 실행합니다.

    Linux & macOS
    aws ssm create-association \ --name AWS-GatherSoftwareInventory \ --targets Key=InstanceIds,Values=* \ --schedule-expression "rate(1 day)" \ --parameters applications=Enabled,awsComponents=Enabled,customInventory=Enabled,instanceDetailedInformation=Enabled,networkConfig=Enabled,services=Enabled,windowsRoles=Enabled,windowsUpdates=Enabled
    Windows
    aws ssm create-association ^ --name AWS-GatherSoftwareInventory ^ --targets Key=InstanceIds,Values=* ^ --schedule-expression "rate(1 day)" ^ --parameters applications=Enabled,awsComponents=Enabled,customInventory=Enabled,instanceDetailedInformation=Enabled,networkConfig=Enabled,services=Enabled,windowsRoles=Enabled,windowsUpdates=Enabled
참고

이 명령은 Inventory가 Windows 레지스트리 또는 파일에 대한 메타데이터를 수집하는 것을 허용하지 않습니다. 이러한 데이터 형식을 인벤토리하려면 다음 절차를 사용하십시오.

관리형 노드에서 수동으로 인벤토리 구성(CLI)

다음 절차를 사용하여 수동으로 인스턴스 ID 또는 태그를 사용해 관리형 노드에 AWS Systems Manager 인벤토리를 구성합니다.

수동으로 관리형 노드에서 인벤토리 구성(CLI)
  1. 아직 하지 않은 경우 AWS Command Line Interface(AWS CLI)를 설치하고 구성합니다.

    자세한 내용은 최신 버전의 AWS CLI 설치 또는 업데이트를 참조하세요.

  2. 다음 명령을 실행하여 노드에서 Systems Manager Inventory를 실행하는 State Manager 연결을 생성합니다. 각 example resource placeholder를 사용자의 정보로 바꿉니다. 이 명령은 6시간마다 서비스를 실행하고 노드에서 네트워크 구성, Windows 업데이트, 애플리케이션 메타데이터를 수집하도록 구성합니다.

    Linux & macOS
    aws ssm create-association \ --name "AWS-GatherSoftwareInventory" \ --targets "Key=instanceids,Values=an_instance_ID" \ --schedule-expression "rate(240 minutes)" \ --output-location "{ \"S3Location\": { \"OutputS3Region\": \"region_ID, for example us-east-2\", \"OutputS3BucketName\": \"amzn-s3-demo-bucket\", \"OutputS3KeyPrefix\": \"Test\" } }" \ --parameters "networkConfig=Enabled,windowsUpdates=Enabled,applications=Enabled"
    Windows
    aws ssm create-association ^ --name "AWS-GatherSoftwareInventory" ^ --targets "Key=instanceids,Values=an_instance_ID" ^ --schedule-expression "rate(240 minutes)" ^ --output-location "{ \"S3Location\": { \"OutputS3Region\": \"region_ID, for example us-east-2\", \"OutputS3BucketName\": \"amzn-s3-demo-bucket\", \"OutputS3KeyPrefix\": \"Test\" } }" ^ --parameters "networkConfig=Enabled,windowsUpdates=Enabled,applications=Enabled"

    시스템은 다음과 같은 정보로 응답합니다.

    {
        "AssociationDescription": {
            "ScheduleExpression": "rate(240 minutes)",
            "OutputLocation": {
                "S3Location": {
                    "OutputS3KeyPrefix": "Test",
                    "OutputS3BucketName": "Test bucket",
                    "OutputS3Region": "us-east-2"
                }
            },
            "Name": "The name you specified",
            "Parameters": {
                "applications": [
                    "Enabled"
                ],
                "networkConfig": [
                    "Enabled"
                ],
                "windowsUpdates": [
                    "Enabled"
                ]
            },
            "Overview": {
                "Status": "Pending",
                "DetailedStatus": "Creating"
            },
            "AssociationId": "1a2b3c4d5e6f7g-1a2b3c-1a2b3c-1a2b3c-1a2b3c4d5e6f7g",
            "DocumentVersion": "$DEFAULT",
            "LastUpdateAssociationDate": 1480544990.06,
            "Date": 1480544990.06,
            "Targets": [
                {
                    "Values": [
                       "i-02573cafcfEXAMPLE"
                    ],
                    "Key": "InstanceIds"
                }
            ]
        }
    }

    대규모 노드 그룹을 대상으로 EC2 태그와 Targets 파라미터를 사용할 수 있습니다. 다음 예를 참조하세요.

    Linux & macOS
    aws ssm create-association \ --name "AWS-GatherSoftwareInventory" \ --targets "Key=tag:Environment,Values=Production" \ --schedule-expression "rate(240 minutes)" \ --output-location "{ \"S3Location\": { \"OutputS3Region\": \"us-east-2\", \"OutputS3BucketName\": \"amzn-s3-demo-bucket\", \"OutputS3KeyPrefix\": \"Test\" } }" \ --parameters "networkConfig=Enabled,windowsUpdates=Enabled,applications=Enabled"
    Windows
    aws ssm create-association ^ --name "AWS-GatherSoftwareInventory" ^ --targets "Key=tag:Environment,Values=Production" ^ --schedule-expression "rate(240 minutes)" ^ --output-location "{ \"S3Location\": { \"OutputS3Region\": \"us-east-2\", \"OutputS3BucketName\": \"amzn-s3-demo-bucket\", \"OutputS3KeyPrefix\": \"Test\" } }" ^ --parameters "networkConfig=Enabled,windowsUpdates=Enabled,applications=Enabled"

    표현식과 함께 fileswindowsRegistry 유형의 인벤토리를 사용하여 Windows Server 노드에서 파일 및 Windows 레지스트리 키를 인벤토리로 만들 수도 있습니다. 이러한 인벤토리 유형에 대한 자세한 내용은 파일 및 Windows 레지스트리 인벤토리 관련 작업를 참조하십시오.

    Linux & macOS
    aws ssm create-association \ --name "AWS-GatherSoftwareInventory" \ --targets "Key=instanceids,Values=i-0704358e3a3da9eb1" \ --schedule-expression "rate(240 minutes)" \ --parameters '{"files":["[{\"Path\": \"C:\\Program Files\", \"Pattern\": [\"*.exe\"], \"Recursive\": true}]"], "windowsRegistry": ["[{\"Path\":\"HKEY_LOCAL_MACHINE\\Software\\Amazon\", \"Recursive\":true}]"]}' \ --profile dev-pdx
    Windows
    aws ssm create-association ^ --name "AWS-GatherSoftwareInventory" ^ --targets "Key=instanceids,Values=i-0704358e3a3da9eb1" ^ --schedule-expression "rate(240 minutes)" ^ --parameters '{"files":["[{\"Path\": \"C:\\Program Files\", \"Pattern\": [\"*.exe\"], \"Recursive\": true}]"], "windowsRegistry": ["[{\"Path\":\"HKEY_LOCAL_MACHINE\\Software\\Amazon\", \"Recursive\":true}]"]}' ^ --profile dev-pdx
  3. 다음 명령을 실행하여 연결 상태를 확인합니다.

    aws ssm describe-instance-associations-status --instance-id an_instance_ID

    시스템은 다음과 같은 정보로 응답합니다.

    {
    "InstanceAssociationStatusInfos": [
             {
                "Status": "Pending",
                "DetailedStatus": "Associated",
                "Name": "reInvent2016PolicyDocumentTest",
                "InstanceId": "i-1a2b3c4d5e6f7g",
                "AssociationId": "1a2b3c4d5e6f7g-1a2b3c-1a2b3c-1a2b3c-1a2b3c4d5e6f7g",
                "DocumentVersion": "1"
            }
    ]
    }