View a markdown version of this page

자습서: AWS CLI를 사용한 서버 환경에 패치 적용 - AWS Systems Manager

자습서: AWS CLI를 사용한 서버 환경에 패치 적용

다음 절차는 사용자 지정 패치 기준, 패치 그룹 및 유지 관리 기간을 사용하여 서버 환경에 패치를 적용하는 방법에 대해 설명합니다.

시작하기 전 준비 사항
Patch Manager 및 패치 관리형 노드 구성(명령줄)
  1. 다음 명령을 실행하여 이름이 Production-Baseline인 Windows 패치 기준을 생성합니다. 이 패치 기준선은 프로덕션 환경의 패치가 릴리스되거나 마지막으로 업데이트되고 7일 후에 승인합니다. 패치 기준에는 프로덕션 환경용임을 나타내는 태그가 지정되어 있습니다.

    참고

    OperatingSystem 파라미터 및 PatchFilters는 패치 기준이 적용되는 대상 관리형 노드의 운영 체제에 따라 달라집니다. 자세한 내용은 OperatingSystemPatchFilter를 참조하십시오.

    Linux & macOS
    aws ssm create-patch-baseline \ --name "Production-Baseline" \ --operating-system "WINDOWS" \ --tags "Key=Environment,Value=Production" \ --approval-rules "PatchRules=[{PatchFilterGroup={PatchFilters=[{Key=MSRC_SEVERITY,Values=[Critical,Important]},{Key=CLASSIFICATION,Values=[SecurityUpdates,Updates,ServicePacks,UpdateRollups,CriticalUpdates]}]},ApproveAfterDays=7}]" \ --description "Baseline containing all updates approved for production systems"
    Windows Server
    aws ssm create-patch-baseline ^ --name "Production-Baseline" ^ --operating-system "WINDOWS" ^ --tags "Key=Environment,Value=Production" ^ --approval-rules "PatchRules=[{PatchFilterGroup={PatchFilters=[{Key=MSRC_SEVERITY,Values=[Critical,Important]},{Key=CLASSIFICATION,Values=[SecurityUpdates,Updates,ServicePacks,UpdateRollups,CriticalUpdates]}]},ApproveAfterDays=7}]" ^ --description "Baseline containing all updates approved for production systems"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "BaselineId":"pb-0c10e65780EXAMPLE"
    }
  2. 다음 명령을 실행하여 두 패치 그룹에 대해 "Production-Baseline" 패치 기준을 등록합니다. 그룹의 이름은 "Database Servers" 및 "Front-End Servers"로 지정됩니다.

    Linux & macOS
    aws ssm register-patch-baseline-for-patch-group \ --baseline-id pb-0c10e65780EXAMPLE \ --patch-group "Database Servers"
    Windows Server
    aws ssm register-patch-baseline-for-patch-group ^ --baseline-id pb-0c10e65780EXAMPLE ^ --patch-group "Database Servers"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "PatchGroup":"Database Servers",
       "BaselineId":"pb-0c10e65780EXAMPLE"
    }
    Linux & macOS
    aws ssm register-patch-baseline-for-patch-group \ --baseline-id pb-0c10e65780EXAMPLE \ --patch-group "Front-End Servers"
    Windows Server
    aws ssm register-patch-baseline-for-patch-group ^ --baseline-id pb-0c10e65780EXAMPLE ^ --patch-group "Front-End Servers"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "PatchGroup":"Front-End Servers",
       "BaselineId":"pb-0c10e65780EXAMPLE"
    }
  3. 다음 명령을 실행하여 프로덕션 서버에 대한 두 개의 유지 관리 기간을 생성합니다. 첫 번째 기간은 매주 화요일 오후 10시에 실행합니다. 두 번째 Window는 매주 토요일 오후 10시에 실행합니다. 또한 유지 관리 기간에는 프로덕션 환경용임을 나타내는 태그가 지정되어 있습니다.

    Linux & macOS
    aws ssm create-maintenance-window \ --name "Production-Tuesdays" \ --tags "Key=Environment,Value=Production" \ --schedule "cron(0 0 22 ? * TUE *)" \ --duration 1 \ --cutoff 0 \ --no-allow-unassociated-targets
    Windows Server
    aws ssm create-maintenance-window ^ --name "Production-Tuesdays" ^ --tags "Key=Environment,Value=Production" ^ --schedule "cron(0 0 22 ? * TUE *)" ^ --duration 1 ^ --cutoff 0 ^ --no-allow-unassociated-targets

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "WindowId":"mw-0c50858d01EXAMPLE"
    }
    Linux & macOS
    aws ssm create-maintenance-window \ --name "Production-Saturdays" \ --tags "Key=Environment,Value=Production" \ --schedule "cron(0 0 22 ? * SAT *)" \ --duration 2 \ --cutoff 0 \ --no-allow-unassociated-targets
    Windows Server
    aws ssm create-maintenance-window ^ --name "Production-Saturdays" ^ --tags "Key=Environment,Value=Production" ^ --schedule "cron(0 0 22 ? * SAT *)" ^ --duration 2 ^ --cutoff 0 ^ --no-allow-unassociated-targets

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "WindowId":"mw-9a8b7c6d5eEXAMPLE"
    }
  4. 다음 명령을 실행하여 DatabaseFront-End 서버 패치 그룹을 해당 유지 관리 기간에 등록합니다.

    Linux & macOS
    aws ssm register-target-with-maintenance-window \ --window-id mw-0c50858d01EXAMPLE \ --targets "Key=tag:PatchGroup,Values=Database Servers" \ --owner-information "Database Servers" \ --resource-type "INSTANCE"
    Windows Server
    aws ssm register-target-with-maintenance-window ^ --window-id mw-0c50858d01EXAMPLE ^ --targets "Key=tag:PatchGroup,Values=Database Servers" ^ --owner-information "Database Servers" ^ --resource-type "INSTANCE"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "WindowTargetId":"e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE"
    }
    Linux & macOS
    aws ssm register-target-with-maintenance-window \ --window-id mw-9a8b7c6d5eEXAMPLE \ --targets "Key=tag:PatchGroup,Values=Front-End Servers" \ --owner-information "Front-End Servers" \ --resource-type "INSTANCE"
    Windows Server
    aws ssm register-target-with-maintenance-window ^ --window-id mw-9a8b7c6d5eEXAMPLE ^ --targets "Key=tag:PatchGroup,Values=Front-End Servers" ^ --owner-information "Front-End Servers" ^ --resource-type "INSTANCE"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "WindowTargetId":"faa01c41-1d57-496c-ba77-ff9caEXAMPLE"
    }
  5. 다음 명령을 실행하여 각 유지 관리 기간 동안 DatabaseFront-End 서버에 누락된 업데이트를 설치하는 패치 작업을 등록합니다.

    Linux & macOS
    aws ssm register-task-with-maintenance-window \ --window-id mw-0c50858d01EXAMPLE \ --targets "Key=WindowTargetIds,Values=e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE" \ --task-arn "AWS-RunPatchBaseline" \ --service-role-arn "arn:aws:iam::123456789012:role/MW-Role" \ --task-type "RUN_COMMAND" \ --max-concurrency 2 \ --max-errors 1 \ --priority 1 \ --task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"
    Windows Server
    aws ssm register-task-with-maintenance-window ^ --window-id mw-0c50858d01EXAMPLE ^ --targets "Key=WindowTargetIds,Values=e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE" ^ --task-arn "AWS-RunPatchBaseline" ^ --service-role-arn "arn:aws:iam::123456789012:role/MW-Role" ^ --task-type "RUN_COMMAND" ^ --max-concurrency 2 ^ --max-errors 1 ^ --priority 1 ^ --task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE"
    }
    Linux & macOS
    aws ssm register-task-with-maintenance-window \ --window-id mw-9a8b7c6d5eEXAMPLE \ --targets "Key=WindowTargetIds,Values=faa01c41-1d57-496c-ba77-ff9caEXAMPLE" \ --task-arn "AWS-RunPatchBaseline" \ --service-role-arn "arn:aws:iam::123456789012:role/MW-Role" \ --task-type "RUN_COMMAND" \ --max-concurrency 2 \ --max-errors 1 \ --priority 1 \ --task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"
    Windows Server
    aws ssm register-task-with-maintenance-window ^ --window-id mw-9a8b7c6d5eEXAMPLE ^ --targets "Key=WindowTargetIds,Values=faa01c41-1d57-496c-ba77-ff9caEXAMPLE" ^ --task-arn "AWS-RunPatchBaseline" ^ --service-role-arn "arn:aws:iam::123456789012:role/MW-Role" ^ --task-type "RUN_COMMAND" ^ --max-concurrency 2 ^ --max-errors 1 ^ --priority 1 ^ --task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "WindowTaskId":"8a5c4629-31b0-4edd-8aea-33698EXAMPLE"
    }
  6. 다음 명령을 실행하여 패치 그룹에 대한 높은 수준의 패치 규정 준수 요약을 확인합니다. 상위 수준의 패치 규정 준수 요약에는 각 패치 상태의 패치가 있는 관리형 노드 수가 포함됩니다.

    참고

    첫 번째 유지 관리 기간 동안 패치 태스크가 실행될 때까지 요약에는 관리형 노드 수가 0으로 표시됩니다.

    Linux & macOS
    aws ssm describe-patch-group-state \ --patch-group "Database Servers"
    Windows Server
    aws ssm describe-patch-group-state ^ --patch-group "Database Servers"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "Instances": number,
       "InstancesWithFailedPatches": number,
       "InstancesWithInstalledOtherPatches": number,
       "InstancesWithInstalledPatches": number,
       "InstancesWithInstalledPendingRebootPatches": number,
       "InstancesWithInstalledRejectedPatches": number,
       "InstancesWithMissingPatches": number,
       "InstancesWithNotApplicablePatches": number,
       "InstancesWithUnreportedNotApplicablePatches": number
    }
  7. 다음 명령을 실행하여 패치 그룹에 대한 관리형 노드별 패치 요약 상태를 확인합니다. 관리형 노드별 요약에는 패치 그룹에 대한 관리형 노드당 각 패치 상태의 여러 패치가 포함됩니다.

    Linux & macOS
    aws ssm describe-instance-patch-states-for-patch-group \ --patch-group "Database Servers"
    Windows Server
    aws ssm describe-instance-patch-states-for-patch-group ^ --patch-group "Database Servers"

    시스템은 다음과 같은 정보를 반환합니다.

    {
       "InstancePatchStates": [ 
          { 
             "BaselineId": "string",
             "FailedCount": number,
             "InstalledCount": number,
             "InstalledOtherCount": number,
             "InstalledPendingRebootCount": number,
             "InstalledRejectedCount": number,
             "InstallOverrideList": "string",
             "InstanceId": "string",
             "LastNoRebootInstallOperationTime": number,
             "MissingCount": number,
             "NotApplicableCount": number,
             "Operation": "string",
             "OperationEndTime": number,
             "OperationStartTime": number,
             "OwnerInformation": "string",
             "PatchGroup": "string",
             "RebootOption": "string",
             "SnapshotId": "string",
             "UnreportedNotApplicableCount": number
          }
       ]
    }

Patch Manager 구성 태스크에 사용할 수 있는 다른 AWS CLI 명령의 예를 보려면 AWS CLI를 사용하여 Patch Manager 리소스 작업 섹션을 참조하세요.