시연: Chef 레시피를 실행하는 연결 생성 - AWS Systems Manager

시연: Chef 레시피를 실행하는 연결 생성

Chef SSM 문서를 사용하여 AWS Systems Manager 레시피를 실행하는 State Manager 연결을 생성할 수 있습니다. State Manager는 AWS-ApplyChefRecipes의 기능입니다. AWS-ApplyChefRecipes SSM 문서를 사용하여 Linux 기반 Systems Manager 관리형 노드를 대상으로 지정할 수 있습니다. 이 문서는 Chef 레시피 실행을 위해 다음과 같은 이점을 제공합니다.

  • 여러 Chef 릴리스(Chef 11~Chef 18)를 지원합니다.

  • 대상 노드에 Chef 클라이언트 소프트웨어를 자동으로 설치합니다.

  • 선택적으로 대상 노드에 대해 Systems Manager 규정 준수 점검을 실행하고 규정 준수 점검 결과를 Amazon Simple Storage Service(Amazon S3) 버킷에 저장합니다.

  • 문서를 한 번 실행할 때 여러 쿡북과 레시피를 실행합니다.

  • 선택적으로 why-run 모드에서 레시피를 실행하여 변경하지 않고 대상 노드에서 변경되는 레시피를 표시합니다.

  • 선택적으로 사용자 지정 JSON 속성을 chef-client 실행에 적용합니다.

  • 사용자가 지정하는 위치에 저장된 소스 파일의 사용자 지정 JSON 속성을 선택적으로 적용합니다.

Git, GitHub, HTTP 또는 Amazon S3 버킷을 AWS-ApplyChefRecipes 문서에서 사용자가 지정하는 Chef 쿡북 및 레시피의 다운로드 소스로 사용할 수 있습니다.

참고

Chef 레시피를 실행하는 연결은 macOS에서 지원되지 않습니다.

사전 조건: 연결, 리포지토리 및 쿡북 설정

AWS-ApplyChefRecipes 문서를 만들기 전에 Chef 쿡북과 쿡북 리포지토리를 준비합니다. 사용하려는 Chef 쿡북이 없는 경우 AWS에서 준비한 테스트 HelloWorld 쿡북을 사용하여 시작할 수 있습니다. AWS-ApplyChefRecipes 문서는 이미 기본적으로 이 쿡북을 가리키고 있습니다. 쿡북은 다음 디렉터리 구조와 유사하게 설정되어야 합니다. 다음 예에서 jenkinsnginx는 Chef 웹사이트의 Chef Supermarket에서 사용할 수 있는 Chef 쿡북의 예입니다.

AWS에서 Chef Supermarket 웹사이트의 쿡북을 공식적으로 지원할 수는 없지만 많은 사람들이 AWS-ApplyChefRecipes 문서를 사용합니다. 다음은 커뮤니티 쿡북을 테스트할 때 확인할 기준의 예입니다.

  • 쿡북은 대상으로 하는 Systems Manager 관리형 노드의 Linux 기반 운영 체제를 지원해야 합니다.

  • 쿡북은 사용자가 사용하는 Chef 클라이언트 버전(Chef 11~Chef 18)에 대해 유효해야 합니다.

  • 쿡북은 Chef Infra Client와 호환되며 Chef 서버가 필요하지 않습니다.

Systems Manager 문서(SSM 문서)가 실행될 때 실행 목록에 지정된 쿡북을 설치할 수 있도록 Chef.io 웹사이트에 연결할 수 있는지 확인합니다. 중첩된 cookbooks 폴더 사용은 지원되지만 필수는 아닙니다. 루트 수준 바로 아래에 쿡북을 저장할 수 있습니다.

<Top-level directory, or the top level of the archive file (ZIP or tgz or tar.gz)> └── cookbooks (optional level) ├── jenkins │ ├── metadata.rb │ └── recipes └── nginx ├── metadata.rb └── recipes
중요

Chef 레시피를 실행하는 State Manager 연결을 생성하기 전에 Chef 클라이언트 버전 값을 None으로 설정하지 않는 한 문서 실행 시 Systems Manager 관리형 노드에 Chef 클라이언트 소프트웨어가 설치된다는 점에 유의하세요. 이 작업은 Chef의 설치 스크립트를 사용하여 사용자 대신 Chef 구성 요소를 설치합니다. AWS-ApplyChefRecipes 문서를 실행하기 전에 기업이 Chef 소프트웨어 사용에 적용되는 라이선스 조건을 포함하여 적용 가능한 법적 요구 사항을 준수할 수 있는지 확인합니다. 자세한 내용은 Chef 웹사이트를 참조하세요.

Systems Manager는 규정 준수 보고서를 Systems Manager 콘솔인 S3 버킷에 제공하거나, Systems Manager API 명령에 대한 응답에서 규정 준수 결과를 사용하도록 만들 수 있습니다. Systems Manager 규정 준수 보고서를 실행하려면 Systems Manager 관리형 노드에 연결된 인스턴스 프로파일에 S3 버킷에 대한 쓰기 권한이 있어야 합니다. 인스턴스 프로파일에는 Systems Manager PutComplianceItem API를 사용할 권한이 있어야 합니다. Systems Manager 규정 준수에 대한 자세한 내용은 AWS Systems Manager Compliance 섹션을 참조하세요.

실행 문서 로깅

State Manager 연결을 사용하여 Systems Manager 문서(SSM 문서)를 실행할 때 문서 실행의 출력을 선택하도록 연결을 구성할 수 있으며 출력을 Amazon S3 또는 Amazon CloudWatch Logs(CloudWatch Logs)로 전송할 수 있습니다. 연결 실행이 완료될 때 문제 해결을 쉽게 하려면 연결이 Amazon S3 버킷 또는 CloudWatch Logs에 명령 출력을 쓰도록 구성되어 있는지 확인합니다. 자세한 내용은 Systems Manager에서 연결 작업 단원을 참조하십시오.

레시피 실행 시 대상에 JSON 속성 적용

연결 실행 중에 대상 노드에 적용할 Chef 클라이언트의 JSON 속성을 지정할 수 있습니다. 연결을 설정할 때 원시 JSON을 제공하거나 Amazon S3에 저장된 JSON 파일의 경로를 제공할 수 있습니다.

레시피가 실행되는 방식을 사용자 정의하려는 경우 레시피 자체를 수정할 필요 없이 JSON 속성을 사용합니다. 예를 들면 다음과 같습니다.

  • 소수의 속성 재정의

    사용자 지정 JSON을 사용하면 사소한 차이를 수용하기 위해 레시피를 여러 버전으로 유지하지 않아도 됩니다.

  • 변수 값 제공

    사용자 지정 JSON을 사용하여, 실행할 때마다 변경될 수 있는 값을 지정합니다. 예를 들어 Chef 쿡북이 결제를 허용하는 타사 애플리케이션을 구성하는 경우 사용자 지정 JSON을 사용하여 결제 엔드포인트 URL을 지정할 수 있습니다.

원시 JSON에 속성 지정

다음은 Chef 레시피의 사용자 지정 JSON 속성 지정에 사용할 수 있는 형식의 예제입니다.

{"filepath":"/tmp/example.txt", "content":"Hello, World!"}
JSON 파일 경로 지정

다음은 Chef 레시피의 사용자 지정 JSON 속성 경로 지정에 사용할 수 있는 형식의 예제입니다.

{"sourceType":"s3", "sourceInfo":"someS3URL1"}, {"sourceType":"s3", "sourceInfo":"someS3URL2"}

쿡북 소스로 Git 사용

AWS-ApplyChefRecipes 문서는 aws:downloadContent 플러그인을 사용하여 Chef 쿡북을 다운로드합니다. Git에서 콘텐츠를 다운로드하려면 Git 리포지토리에 대한 정보를 다음 예제와 같이 JSON 형식으로 지정합니다. 각 example-resource-placeholder를 자신의 정보로 바꿉니다.

{ "repository":"GitCookbookRepository", "privateSSHKey":"{{ssm-secure:ssh-key-secure-string-parameter}}", "skipHostKeyChecking":"false", "getOptions":"branch:refs/head/main", "username":"{{ssm-secure:username-secure-string-parameter}}", "password":"{{ssm-secure:password-secure-string-parameter}}" }

GitHub을 쿡북 소스로 사용

AWS-ApplyChefRecipes 문서는aws:downloadContent 플러그인을 사용하여 쿡북을 다운로드합니다. GitHub에서 콘텐츠를 다운로드하려면 GitHub 리포지토리에 대한 정보를 다음 예제와 같이 JSON 형식으로 지정합니다. 각 example-resource-placeholder를 자신의 정보로 바꿉니다.

{ "owner":"TestUser", "repository":"GitHubCookbookRepository", "path":"cookbooks/HelloWorld", "getOptions":"branch:refs/head/main", "tokenInfo":"{{ssm-secure:token-secure-string-parameter}}" }

쿡북 소스로 HTTP 사용

Chef 쿡북을 사용자 지정 HTTP 위치에 단일 .zip 또는 tar.gz 파일이나 디렉터리 구조로 저장할 수 있습니다. HTTP에서 콘텐츠를 다운로드하려면 파일 또는 디렉터리 경로를 다음 예제와 같이 JSON 형식으로 지정합니다. 각 example-resource-placeholder를 자신의 정보로 바꿉니다.

{ "url":"https://my.website.com/chef-cookbooks/HelloWorld.zip", "allowInsecureDownload":"false", "authMethod":"Basic", "username":"{{ssm-secure:username-secure-string-parameter}}", "password":"{{ssm-secure:password-secure-string-parameter}}" }

Amazon S3를 쿡북 소스로 사용

Amazon S3에서 Chef 쿡북을 단일 .zip 또는 tar.gz 파일이나 디렉터리 구조로 저장하고 다운로드할 수도 있습니다. Amazon S3에서 콘텐츠를 다운로드하려면 파일 경로를 다음 예제와 같이 JSON 형식으로 지정합니다. 각 example-resource-placeholder를 자신의 정보로 바꿉니다.

예제 1: 특정 쿡북 다운로드

{ "path":"https://s3.amazonaws.com/chef-cookbooks/HelloWorld.zip" }

예 2: 디렉터리 콘텐츠 다운로드

{ "path":"https://s3.amazonaws.com/chef-cookbooks-test/HelloWorld" }
중요

Amazon S3를 지정하면 AmazonS3ReadOnlyAccess 정책을 사용하여 관리형 노드에 있는 AWS Identity and Access Management(IAM) 노드 프로파일을 구성해야 합니다. 자세한 내용은 Systems Manager에 필요한 인스턴스 권한 구성을 참조하세요.

Chef 레시피를 실행하는 연결 생성(콘솔)

다음 절차에서는 Systems Manager 콘솔을 사용하여 AWS-ApplyChefRecipes 문서로 Chef 쿡북을 실행하는 State Manager 연결을 생성하는 방법을 설명합니다.

  1. AWS Systems Manager 콘솔(https://console.aws.amazon.com/systems-manager/)을 엽니다.

  2. 탐색 창에서 State Manager를 선택합니다.

  3. [State Manager]를 선택하고 [연결 생성(Create association)]을 선택합니다.

  4. 이름에 연결의 목적을 기억하는 데 도움이 되는 이름을 입력합니다.

  5. [문서(Document)] 목록에서 AWS-ApplyChefRecipes를 선택합니다.

  6. 파라미터에서 소수 유형Git, GitHub, HTTP 또는 S3 중에서 선택합니다.

  7. 소스 정보에는 6단계에서 선택한 소스 유형에 적합한 형식을 사용하여 쿡북 소스 정보를 입력합니다. 자세한 정보는 다음 주제를 참조하세요.

  8. Run list(실행 목록)에서 다음과 같이 각 레시피를 쉼표로 구분하여 실행할 레시피를 나열합니다. 쉼표 뒤에 공백을 넣지 않습니다. 각 example-resource-placeholder를 자신의 정보로 바꿉니다.

    recipe[cookbook-name1::recipe-name],recipe[cookbook-name2::recipe-name]
  9. (선택 사항) Chef 클라이언트를 통해 대상 노드에 전달하려는 사용자 지정 JSON 속성을 지정합니다.

    1. JSON 속성 콘텐츠에서 Chef 클라이언트를 통해 대상 노드에 전달하려는 모든 속성을 추가합니다.

    2. JSON 속성 소스에서 Chef 클라이언트를 통해 대상 노드에 전달하려는 모든 속성의 경로를 추가합니다.

    자세한 내용은 레시피 실행 시 대상에 JSON 속성 적용 단원을 참조하십시오.

  10. Chef 클라이언트 버전에서 Chef 버전을 지정합니다. 유효한 값은 11~18 또는 None입니다. 11부터 18까지의 숫자를 지정하면 Systems Manager에서는 대상 노드에 올바른 Chef 클라이언트 버전을 설치합니다. None을 지정한 경우 Systems Manager는 문서의 레시피를 실행하기 전에 대상 노드에 Chef 클라이언트를 설치하지 않습니다.

  11. (옵션) Chef 클라이언트 인수에서 사용 중인 Chef 버전에 대해 지원되는 추가 인수를 지정합니다. 지원되는 인수에 대한 자세한 내용을 보려면 Chef 클라이언트를 실행하는 노드에서 chef-client -h를 실행하세요.

  12. (옵션) Why-run을 설정하여 대상 노드를 실제로 변경하지 않고 레시피를 실행할 경우 대상 노드에 적용되는 변경 사항을 표시합니다.

  13. [규정 준수 심각도(Compliance severity)]에서 보고할 Systems Manager Compliance 결과의 심각도를 선택합니다. 규정 준수 보고는 지정한 심각도 수준과 함께 연결 상태가 규정을 준수하는지 여부를 나타냅니다. Compliance 보고서는 [Compliance 보고서 버킷(Compliance report bucket)] 파라미터 값(14단계)으로 지정하는 S3 버킷에 저장됩니다. Compliance에 대한 자세한 내용은 이 가이드의 Compliance 작업 섹션을 참조하세요.

    규정 준수 검사는 Chef 레시피 및 노드 리소스에 지정된 구성 간의 드리프트를 측정합니다. 유효한 값은 Critical, High, Medium, Low, Informational, Unspecified 또는 None입니다. 규정 준수 보고를 건너뛰려면 None을 선택합니다.

  14. 규정 준수 유형에서 결과를 보고할 규정 준수 유형을 지정합니다. 유효한 값은 State Manager 연결의 경우 Association 또는 Custom:custom_type입니다. 기본 값은 Custom:Chef입니다.

  15. Compliance 보고서 버킷의 경우 리소스 구성 및 Compliance 결과를 포함하여 이 문서에서 수행한 모든 Chef에 대한 정보를 저장할 S3 버킷의 이름을 입력합니다.

  16. Rate control(속도 제어)에서 관리형 노드 플릿 간에 State Manager 연결을 실행하기 위한 옵션을 구성합니다. 속도 제어 사용에 대한 자세한 내용은 State Manager 연결에서의 대상 및 속도 제어 정보 섹션을 참조하세요.

    동시성에서 옵션을 선택합니다.

    • 대상을 선택하여 연결을 동시에 실행할 수 있는 대상 수(절대 개수)를 입력합니다.

    • 백분율을 선택하여 연결을 동시에 실행할 수 있는 대상의 백분율을 입력합니다.

    Error threshold(오류 임계값)에서 옵션을 선택합니다.

    • 오류를 선택하여 State Manager에서 추가 대상에 대한 연결 실행을 중지하기 전에 허용되는 절대 오류 수를 입력합니다.

    • 백분율을 선택하여 State Manager에서 추가 대상에 대한 연결 실행을 중지하기 전에 허용되는 오류 비율을 입력합니다.

  17. (선택 사항) 출력 옵션에서 명령 출력을 파일에 저장하려면 S3 버킷에 쓰기 활성화 옆의 상자를 선택합니다. 상자에 버킷 및 접두사(폴더) 이름을 입력합니다.

    참고

    데이터를 S3 버킷에 쓰는 기능을 부여하는 S3 권한은 이 작업을 수행하는 IAM 사용자의 권한이 아닌 관리형 노드에 할당된 인스턴스 프로파일의 권한입니다. 자세한 내용은 Systems Manager에 필요한 인스턴스 권한 구성이나 하이브리드 환경을 위한 IAM 서비스 역할 생성을 참조하세요. 또한 지정된 S3 버킷이 다른 AWS 계정에 있는 경우 관리형 노드와 연결된 인스턴스 프로파일 또는 IAM 서비스 역할은 해당 버킷에 쓸 수 있는 권한이 있어야 합니다.

  18. 연결 생성을 선택합니다.

Chef 레시피를 실행하는 연결 생성(CLI)

다음 절차에서는 AWS Command Line Interface(AWS CLI)를 사용하여 AWS-ApplyChefRecipes 문서로 Chef 쿡북을 실행하는 State Manager 연결을 생성하는 방법을 설명합니다.

  1. 아직 하지 않은 경우 AWS Command Line Interface(AWS CLI)를 설치하고 구성합니다.

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

  2. 다음과 같은 명령 중 하나를 실행하여 지정된 태그가 있는 대상 노드에서 Chef 쿡북을 실행하는 연결을 생성합니다. 쿡북 소스 유형 및 운영 체제에 적합한 명령을 사용합니다. 각 example-resource-placeholder를 자신의 정보로 바꿉니다.

    1. Git 소스

      Linux & macOS
      aws ssm create-association --name "AWS-ApplyChefRecipes" \ --targets Key=tag:TagKey,Values=TagValue \ --parameters '{"SourceType":["Git"],"SourceInfo":["{\"repository\":\"repository-name\", \"getOptions\": \"branch:branch-name\", \"username\": \"{{ ssm-secure:username-secure-string-parameter }}\", \"password\": \"{{ ssm-secure:password-secure-string-parameter }}\"}"], "RunList":["{\"recipe[cookbook-name-1::recipe-name]\", \"recipe[cookbook-name-2::recipe-name]\"}"], "JsonAttributesContent": ["{custom-json-content}"], "JsonAttributesSources": "{\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-1\"}, {\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-2\"}", "ChefClientVersion": ["version-number"], "ChefClientArguments":["{chef-client-arguments}"], "WhyRun": boolean, "ComplianceSeverity": ["severity-value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["s3-bucket-name"]}' \ --association-name "name" \ --schedule-expression "cron-or-rate-expression"
      Windows
      aws ssm create-association --name "AWS-ApplyChefRecipes" ^ --targets Key=tag:TagKey,Values=TagValue ^ --parameters '{"SourceType":["Git"],"SourceInfo":["{\"repository\":\"repository-name\", \"getOptions\": \"branch:branch-name\", \"username\": \"{{ ssm-secure:username-secure-string-parameter }}\", \"password\": \"{{ ssm-secure:password-secure-string-parameter }}\"}"], "RunList":["{\"recipe[cookbook-name-1::recipe-name]\", \"recipe[cookbook-name-2::recipe-name]\"}"], "JsonAttributesContent": ["{custom-json}"], "JsonAttributesSources": "{\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-1\"}, {\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-2\"}", "ChefClientVersion": ["version-number"], "ChefClientArguments":["{chef-client-arguments}"], "WhyRun": boolean, "ComplianceSeverity": ["severity-value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["s3-bucket-name"]}' ^ --association-name "name" ^ --schedule-expression "cron-or-rate-expression"

    2. GitHub 소스

      Linux & macOS
      aws ssm create-association --name "AWS-ApplyChefRecipes" \ --targets Key=tag:TagKey,Values=TagValue \ --parameters '{"SourceType":["GitHub"],"SourceInfo":["{\"owner\":\"owner-name\", \"repository\": \"name\", \"path\": \"path-to-directory-or-cookbook-to-download\", \"getOptions\": \"branch:branch-name\"}"], "RunList":["{\"recipe[cookbook-name-1::recipe-name]\", \"recipe[cookbook-name-2::recipe-name]\"}"], "JsonAttributesContent": ["{custom-json}"], "ChefClientVersion": ["version-number"], "ChefClientArguments":["{chef-client-arguments}"], "WhyRun": boolean, "ComplianceSeverity": ["severity-value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["s3-bucket-name"]}' \ --association-name "name" \ --schedule-expression "cron-or-rate-expression"
      Windows
      aws ssm create-association --name "AWS-ApplyChefRecipes" ^ --targets Key=tag:TagKey,Values=TagValue \ --parameters '{"SourceType":["GitHub"],"SourceInfo":["{\"owner\":\"owner-name\", \"repository\": \"name\", \"path\": \"path-to-directory-or-cookbook-to-download\", \"getOptions\": \"branch:branch-name\"}"], "RunList":["{\"recipe[cookbook-name-1::recipe-name]\", \"recipe[cookbook-name-2::recipe-name]\"}"], "JsonAttributesContent": ["{custom-json}"], "ChefClientVersion": ["version-number"], "ChefClientArguments":["{chef-client-arguments}"], "WhyRun": boolean, "ComplianceSeverity": ["severity-value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["s3-bucket-name"]}' ^ --association-name "name" ^ --schedule-expression "cron-or-rate-expression"

      다음 예를 참고하세요

      Linux & macOS
      aws ssm create-association --name "AWS-ApplyChefRecipes" \ --targets Key=tag:OS,Values=Linux \ --parameters '{"SourceType":["GitHub"],"SourceInfo":["{\"owner\":\"ChefRecipeTest\", \"repository\": \"ChefCookbooks\", \"path\": \"cookbooks/HelloWorld\", \"getOptions\": \"branch:master\"}"], "RunList":["{\"recipe[HelloWorld::HelloWorldRecipe]\", \"recipe[HelloWorld::InstallApp]\"}"], "JsonAttributesContent": ["{\"state\": \"visible\",\"colors\": {\"foreground\": \"light-blue\",\"background\": \"dark-gray\"}}"], "ChefClientVersion": ["14"], "ChefClientArguments":["{--fips}"], "WhyRun": false, "ComplianceSeverity": ["Medium"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["ChefComplianceResultsBucket"]}' \ --association-name "MyChefAssociation" \ --schedule-expression "cron(0 2 ? * SUN *)"
      Windows
      aws ssm create-association --name "AWS-ApplyChefRecipes" ^ --targets Key=tag:OS,Values=Linux ^ --parameters '{"SourceType":["GitHub"],"SourceInfo":["{\"owner\":\"ChefRecipeTest\", \"repository\": \"ChefCookbooks\", \"path\": \"cookbooks/HelloWorld\", \"getOptions\": \"branch:master\"}"], "RunList":["{\"recipe[HelloWorld::HelloWorldRecipe]\", \"recipe[HelloWorld::InstallApp]\"}"], "JsonAttributesContent": ["{\"state\": \"visible\",\"colors\": {\"foreground\": \"light-blue\",\"background\": \"dark-gray\"}}"], "ChefClientVersion": ["14"], "ChefClientArguments":["{--fips}"], "WhyRun": false, "ComplianceSeverity": ["Medium"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["ChefComplianceResultsBucket"]}' ^ --association-name "MyChefAssociation" ^ --schedule-expression "cron(0 2 ? * SUN *)"
    3. HTTP 소스

      Linux & macOS
      aws ssm create-association --name "AWS-ApplyChefRecipes" \ --targets Key=tag:TagKey,Values=TagValue \ --parameters '{"SourceType":["HTTP"],"SourceInfo":["{\"url\":\"url-to-zip-file|directory|cookbook\", \"authMethod\": \"auth-method\", \"username\": \"{{ ssm-secure:username-secure-string-parameter }}\", \"password\": \"{{ ssm-secure:password-secure-string-parameter }}\"}"], "RunList":["{\"recipe[cookbook-name-1::recipe-name]\", \"recipe[cookbook-name-2::recipe-name]\"}"], "JsonAttributesContent": ["{custom-json-content}"], "JsonAttributesSources": "{\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-1\"}, {\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-2\"}", "ChefClientVersion": ["version-number"], "ChefClientArguments":["{chef-client-arguments}"], "WhyRun": boolean, "ComplianceSeverity": ["severity-value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["s3-bucket-name"]}' \ --association-name "name" \ --schedule-expression "cron-or-rate-expression"
      Windows
      aws ssm create-association --name "AWS-ApplyChefRecipes" ^ --targets Key=tag:TagKey,Values=TagValue ^ --parameters '{"SourceType":["HTTP"],"SourceInfo":["{\"url\":\"url-to-zip-file|directory|cookbook\", \"authMethod\": \"auth-method\", \"username\": \"{{ ssm-secure:username-secure-string-parameter }}\", \"password\": \"{{ ssm-secure:password-secure-string-parameter }}\"}"], "RunList":["{\"recipe[cookbook-name-1::recipe-name]\", \"recipe[cookbook-name-2::recipe-name]\"}"], "JsonAttributesContent": ["{custom-json-content}"], "JsonAttributesSources": "{\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-1\"}, {\"sourceType\":\"s3\", \"sourceInfo\":\"s3-bucket-endpoint-2\"}", "ChefClientVersion": ["version-number"], "ChefClientArguments":["{chef-client-arguments}"], "WhyRun": boolean, "ComplianceSeverity": ["severity-value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["s3-bucket-name"]}' \ --association-name "name" ^ --schedule-expression "cron-or-rate-expression"
    4. Amazon S3 소스

      Linux & macOS
      aws ssm create-association --name "AWS-ApplyChefRecipes" \ --targets Key=tag:TagKey,Values=TagValue \ --parameters '{"SourceType":["S3"],"SourceInfo":["{\"path\":\"https://s3.amazonaws.com/path_to_Zip_file,_directory,_or_cookbook_to_download\"}"], "RunList":["{\"recipe[cookbook_name1::recipe_name]\", \"recipe[cookbook_name2::recipe_name]\"}"], "JsonAttributesContent": ["{Custom_JSON}"], "ChefClientVersion": ["version_number"], "ChefClientArguments":["{chef_client_arguments}"], "WhyRun": true_or_false, "ComplianceSeverity": ["severity_value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["DOC-EXAMPLE-BUCKET"]}' \ --association-name "name" \ --schedule-expression "cron_or_rate_expression"
      Windows
      aws ssm create-association --name "AWS-ApplyChefRecipes" ^ --targets Key=tag:TagKey,Values=TagValue ^ --parameters '{"SourceType":["S3"],"SourceInfo":["{\"path\":\"https://s3.amazonaws.com/path_to_Zip_file,_directory,_or_cookbook_to_download\"}"], "RunList":["{\"recipe[cookbook_name1::recipe_name]\", \"recipe[cookbook_name2::recipe_name]\"}"], "JsonAttributesContent": ["{Custom_JSON}"], "ChefClientVersion": ["version_number"], "ChefClientArguments":["{chef_client_arguments}"], "WhyRun": true_or_false, "ComplianceSeverity": ["severity_value"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["DOC-EXAMPLE-BUCKET"]}' ^ --association-name "name" ^ --schedule-expression "cron_or_rate_expression"

      다음 예를 참고하세요

      Linux & macOS
      aws ssm create-association --name "AWS-ApplyChefRecipes" \ --targets "Key=tag:OS,Values= Linux" \ --parameters '{"SourceType":["S3"],"SourceInfo":["{\"path\":\"https://s3.amazonaws.com/DOC-EXAMPLE-BUCKET/HelloWorld\"}"], "RunList":["{\"recipe[HelloWorld::HelloWorldRecipe]\", \"recipe[HelloWorld::InstallApp]\"}"], "JsonAttributesContent": ["{\"state\": \"visible\",\"colors\": {\"foreground\": \"light-blue\",\"background\": \"dark-gray\"}}"], "ChefClientVersion": ["14"], "ChefClientArguments":["{--fips}"], "WhyRun": false, "ComplianceSeverity": ["Medium"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["ChefComplianceResultsBucket"]}' \ --association-name "name" \ --schedule-expression "cron(0 2 ? * SUN *)"
      Windows
      aws ssm create-association --name "AWS-ApplyChefRecipes" ^ --targets "Key=tag:OS,Values= Linux" ^ --parameters '{"SourceType":["S3"],"SourceInfo":["{\"path\":\"https://s3.amazonaws.com/DOC-EXAMPLE-BUCKET/HelloWorld\"}"], "RunList":["{\"recipe[HelloWorld::HelloWorldRecipe]\", \"recipe[HelloWorld::InstallApp]\"}"], "JsonAttributesContent": ["{\"state\": \"visible\",\"colors\": {\"foreground\": \"light-blue\",\"background\": \"dark-gray\"}}"], "ChefClientVersion": ["14"], "ChefClientArguments":["{--fips}"], "WhyRun": false, "ComplianceSeverity": ["Medium"], "ComplianceType": ["Custom:Chef"], "ComplianceReportBucket": ["ChefComplianceResultsBucket"]}' ^ --association-name "name" ^ --schedule-expression "cron(0 2 ? * SUN *)"

      시스템에서 연결이 생성되며, 지정된 cron 또는 rate 표현식이 이를 방해하지 않는 한 시스템에서는 대상 노드에서 연결을 실행합니다.

      참고

      State Manager 연결은 cron 및 rate 표현식 중 일부를 지원하지 않습니다. 연결에 대한 cron 및 rate 표현식을 생성하는 방법에 대한 자세한 내용은 참조: Systems Manager용 Cron 및 Rate 표현식 섹션을 참조하세요.

  3. 다음 명령을 실행하여 방금 생성한 연결의 상태를 봅니다.

    aws ssm describe-association --association-id "ID"

Chef 리소스 규정 준수 세부 정보 보기

Systems Manager는 AWS-ApplyChefRecipes 문서를 실행했을 때 지정한 Amazon S3 Compliance 보고서 버킷 값에서 Chef 관리형 리소스에 대한 규정 준수 정보를 수집합니다. S3 버킷에서 Chef 리소스 실패에 대한 정보를 검색하는 데는 시간이 많이 걸릴 수 있습니다. 대신, Systems Manager [Compliance] 페이지에서 이 정보를 볼 수 있습니다.

Systems Manager Compliance 검사는 가장 최근의 Chef 실행에서 생성되거나 확인된 관리형 노드의 리소스에 대한 정보를 수집합니다. 리소스에는 파일, 디렉터리, systemd 서비스, yum 패키지, 템플릿 파일, gem 패키지 및 종속 쿡북 등이 포함될 수 있습니다.

규정 준수 리소스 요약 섹션에 실패한 리소스의 수가 표시됩니다. 다음 예에서 ComplianceTypeCustom:Chef이고 한 개의 리소스가 규정 미준수입니다.

참고

Custom:ChefAWS-ApplyChefRecipes 문서의 기본 ComplianceType 값입니다. 이 값은 사용자 지정 가능합니다.

[Compliance] 페이지의 [Compliance 리소스 요약(Compliance resources summary)] 섹션에서 개수 보기.

[리소스에 대한 세부 정보 개요(Details overview for resources)] 섹션에 규정 미준수 AWS 리소스에 대한 정보가 표시됩니다. 이 섹션에는 규정 준수가 실행된 Chef 리소스 유형, 문제의 심각도, 규정 준수 상태 및 추가 정보(해당하는 경우)에 대한 링크도 포함됩니다.

Chef 관리형 리소스 실패에 대한 규정 준수 세부 정보 보기

[출력 보기(View output)]는 세부 상태의 마지막 4,000자를 표시합니다. Systems Manager는 예외를 첫 번째 요소로 시작하여 자세한 메시지를 찾아 4,000자 할당량에 도달할 때까지 표시합니다. 이 프로세스는 예외가 발생되기 전에 출력된 긴 메시지(문제 해결을 위해 가장 관련성이 높은 메시지)를 표시합니다.

규정 준수 정보를 보는 방법에 대한 자세한 내용은 AWS Systems Manager Compliance 섹션을 참조하세요.

연결 실패가 규정 준수 보고에 미치는 영향

State Manager 연결이 실패한 경우에는 규정 준수 데이터가 보고되지 않습니다. 예를 들어, Systems Manager가 노드에 액세스할 권한이 없는 S3 버킷에서 Chef 쿡북을 다운로드하려고 하면 연결이 실패하고 Systems Manager가 어떠한 규정 준수 데이터도 보고되지 않습니다.