Skip to content

Commit

Permalink
aws_ssm connection: add support for SSM document
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien Brochet committed Jan 19, 2022
1 parent 116f1e5 commit e259b9f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion plugins/connection/aws_ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
version_added: 2.2.0
vars:
- name: ansible_aws_ssm_bucket_sse_kms_key_id
ssm_document:
description: SSM document to use when connecting.
vars:
- name: ansible_aws_ssm_document
'''

EXAMPLES = r'''
Expand Down Expand Up @@ -188,6 +192,19 @@
yum:
name: nginx
state: present
# Install a Nginx Package on Linux Instance; with dedicated SSM document
- name: Install a Nginx Package
vars:
ansible_connection: aws_ssm
ansible_aws_ssm_bucket_name: nameofthebucket
ansible_aws_ssm_region: us-west-2
ansible_aws_ssm_document: nameofthecustomdocument
tasks:
- name: Install a Nginx Package
yum:
name: nginx
state: present
'''

import os
Expand Down Expand Up @@ -343,7 +360,11 @@ def start_session(self):
ssm_parameters = dict()
client = self._get_boto_client('ssm', region_name=region_name, profile_name=profile_name)
self._client = client
response = client.start_session(Target=self.instance_id, Parameters=ssm_parameters)
start_session_args = dict(Target=self.instance_id, Parameters=ssm_parameters)
document_name = self.get_option('ssm_document')
if document_name is not None:
start_session_args['DocumentName'] = document_name
response = client.start_session(**start_session_args)
self._session_id = response['SessionId']

cmd = [
Expand Down

0 comments on commit e259b9f

Please sign in to comment.