LoginSignup
0
0

More than 5 years have passed since last update.

[JAWS-UG CLI]Directory Service:#32-3 ドメインへの参加、ユーザの作成

Last updated at Posted at 2015-11-08

このハンズオンについて

  • このハンズオンでは、Directory Serviceで作成したディレクトリのユーザでManagement Consoleにログインするまでの作業を実施します。
  • 今回のハンズオンでは、AD-Connectorは対象外とします。
  • 一部の操作はManagement Consoleで実施します。
  • Macをお使いの方は、Windows Serverでリモートデスクトップ接続が出来るアプリをご用意ください。
  • Windows Serverをドメインに参加させるため、SSMを使用します。SSMが利用可能なリージョンを利用してください。この手順ではオレゴンを利用します。

前提条件

バージョン確認

このハンズオンは以下のバージョンで動作確認を行いました。

コマンド
aws --version
結果
aws-cli/1.9.5 Python/2.7.10 Linux/4.1.10-17.31.amzn1.x86_64 botocore/1.3.5

必要な権限

作業にあたっては、以下の権限を有したIAMユーザもしくはIAMロールを利用してください。

  • EC2に対するフルコントロール権限
  • Directory Serviceに関するフルコントロール権限
  • IAMに関するフルコントロール権限
  • SSMに関するフルコントロール権限

0. 準備

リージョンを指定

コマンド
export AWS_DEFAULT_REGION='us-west-2'

資格情報を確認

コマンド
aws configure list
結果
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************PZ4A         iam-role
secret_key     ****************AZ55         iam-role
    region                us-west-2              env    AWS_DEFAULT_REGION

変数の確認

コマンド
cat << ETX

    DS_ID: "${DS_ID}"
    Domain Name: ${DS_NAME}
    Name Server 1: ${DNS_IP1}
    Name Server 2: ${DNS_IP2}

ETX
結果
    DS_ID: "ds-**********"
    Domain Name: jawsug.local
    Name Server 1: 10.0.0.10
    Name Server 2: 10.0.1.211

1. ドメイン参加

Windows ServerをDirectory Serviceで作成したディレクトリにドメイン参加させます。

Documentの定義

コマンド
SSM_DOCUMENT_FILE='ssm_document.json'

cat << EOF > ${SSM_DOCUMENT_FILE}
{
    "schemaVersion": "1.0",
    "description": "Sample configuration to join an instance to a domain",
    "runtimeConfig": {
        "aws:domainJoin": {
            "properties": {
                "directoryId": "${DS_ID}",
                "directoryName": "${DS_NAME}",
                "dnsIpAddresses": [
                    "${DNS_IP1}",
                    "${DNS_IP2}"
                ]
            }
        }
    }
}
EOF

JSONファイルを検証

コマンド
jsonlint -q ${SSM_DOCUMENT_FILE}

Documentの内容を確認

コマンド
cat ${SSM_DOCUMENT_FILE}
結果
{
    "schemaVersion": "1.0",
    "description": "Sample configuration to join an instance to a domain",
    "runtimeConfig": {
        "aws:domainJoin": {
            "properties": {
                "directoryId": "d-**********",
                "directoryName": "jawsug.local",
                "directoryOU": "OU=Computers,DC=jawsug,DC=local",
                "dnsIpAddresses": [
                    "10.0.0.10",
                    "10.0.1.211"
                ]
            }
        }
    }
}

同名のDocumentが存在しないことを確認

コマンド
DOC_NAME='DomainJoin'
コマンド
aws ssm get-document --name ${DOC_NAME}
結果
A client error (InvalidDocument) occurred when calling the GetDocument operation: None

Documentの作成

コマンド
aws ssm create-document --content file://${SSM_DOCUMENT_FILE} --name ${DOC_NAME}
結果
{
    "DocumentDescription": {
        "Status": "Creating",
        "Sha1": "****************************************",
        "Description": "Sample configuration to join an instance to a domain",
        "PlatformTypes": [
            "Windows"
        ],
        "CreatedDate": 1446988830.672,
        "Name": "DomainJoin"
    }
}

確認

(EC2Run Commandのリリースで既定のドキュメントが増えたもよう。)

コマンド
aws ssm list-documents
結果
{
    "DocumentIdentifiers": [
        {
            "Name": "DomainJoin",
            "PlatformTypes": [
                "Windows"
            ]
        },
        {
            "Name": "AWS-ConfigureCloudWatch",
            "PlatformTypes": [
                "Windows"
            ]
        },
        {
            "Name": "AWS-ConfigureWindowsUpdate",
            "PlatformTypes": [
                "Windows"
            ]
        },
        {
            "Name": "AWS-InstallApplication",
            "PlatformTypes": [
                "Windows"
            ]
        },
        {
            "Name": "AWS-InstallPowerShellModule",
            "PlatformTypes": [
                "Windows"
            ]
        },
        {
            "Name": "AWS-JoinDirectoryServiceDomain",
            "PlatformTypes": [
                "Windows"
            ]
        },
        {
            "Name": "AWS-RunPowerShellScript",
            "PlatformTypes": [
                "Windows"
            ]
        },
        {
            "Name": "AWS-UpdateEC2Config",
            "PlatformTypes": [
                "Windows"
            ]
        }
    ]
}
コマンド
aws ssm get-document --name ${DOC_NAME}
結果
{
    "Content": "{\n    \"schemaVersion\": \"1.0\",\n    \"description\": \"Sample configuration to join an instance to a domain\",\n    \"runtimeConfig\": {\n        \"aws:domainJoin\": {\n            \"properties\": {\n                \"directoryId\": \"d-926738edc0\",\n                \"directoryName\": \"jawsug.local\",\n                \"dnsIpAddresses\": [\n                    \"10.0.0.192\",\n                    \"10.0.1.227\"\n                ]\n            }\n        }\n    }\n}\n",
    "Name": "DomainJoin"
}

パラメータの確認

コマンド
cat << ETX

   DOC_NAME: ${DOC_NAME}
   INSTANCE_ID: ${INSTANCE_ID}

ETX
結果
   DOC_NAME: DomainJoin
   INSTANCE_ID: i-********

サーバへの関連づけ

コマンド
aws ssm create-association --name ${DOC_NAME} --instance-id ${INSTANCE_ID}
結果
{
    "AssociationDescription": {
        "InstanceId": "i-********",
        "Date": 1445770208.736,
        "Name": "DomainJoin",
        "Status": {
            "Date": 1445770208.736,
            "Message": "Associated with DomainJoin",
            "Name": "Associated"
        }
    }
}

確認

コマンド
aws ssm list-associations --association-filter-list key=InstanceId,value=${INSTANCE_ID}
結果
{
    "Associations": [
        {
            "InstanceId": "i-********",
            "Name": "DomainJoin"
        }
    ]
}

ドメインに参加できていることを確認

ドメイン参加が完了するまでに時間がかかる場合があります。
(そのため、ここで少し休憩します。)
ドメインの参加がどうしても成功しない場合、aws ec2 get-password-dataで取得したローカル管理者のパスワードでログインし、手動でドメインに参加してください。
(手順は当日に画面でご案内します。)

コマンド
aws ssm describe-association --name ${DOC_NAME} --instance-id ${INSTANCE_ID}
結果
{
    "AssociationDescription": {
        "InstanceId": "i-********",
        "Date": 1446441382.794,
        "Name": "DomainJoin",
        "Status": {
            "Date": 1446441751.32,
            "AdditionalInfo": "{\"lang\":\"en-US\",\"name\":\"EC2Config\",\"os\":\"Windows Server 2012 Standard\",\"osver\":\"6.2.9200\",\"ver\":\"3.10.442\"}",
            "Message": "status:Passed, code:0, message:RuntimeStatusCounts=[Passed=1], RuntimeStatus=[aws:domainJoin={Passed}]",
            "Name": "Success"
        }
    }
}

(以下、失敗例)

コマンド
aws ssm describe-association --name ${DOC_NAME} --instance-id ${INSTANCE_ID}
結果
{
    "AssociationDescription": {
        "InstanceId": "i-********",
        "Date": 1445788509.45,
        "Name": "DomainJoin",
        "Status": {
            "Date": 1445788629.156,
            "AdditionalInfo": "{\"lang\":\"en-US\",\"name\":\"EC2Config\",\"os\":\"Windows Server 2012 Standard\",\"osver\":\"6.2.9200\",\"ver\":\"3.10.442\"}",
            "Message": "status:Failed, code:0, message:RuntimeStatusCounts=[Failed=1], RuntimeStatus=[aws:domainJoin={Failed,Could not create computer. RequestId: 0b679615-7b31-11e5-aa94-d38a3e9e11cc : RequestId: 0b679615-7b31-11e5-aa94-d38a3e9e11cc}]",
            "Name": "Failed"
        }
    }
}

2. ドメイン管理ツールのインストール

ツールのインストール

Macをご利用の方はリモートデスクトップが出来る環境を準備します
https://itunes.apple.com/jp/app/microsoft-remote-desktop/id715768417?mt=12

ログイン

リモートデスクトップ接続を行うツールでドメインの管理者ユーザでログインします。
(ログインできなかった場合は、ローカルユーザでログインしてみてください。)

IPアドレスはこちらで確認
http://qiita.com/domokun70cm/items/38ffd040b805e2928d62#%E3%83%91%E3%83%96%E3%83%AA%E3%83%83%E3%82%AFip%E3%82%92%E7%A2%BA%E8%AA%8D

Account Password
jawsug.local\administrator ********

Active Directoryの管理ツールをインストール

PowerShellのコンソールを開き、以下のコマンドを実行

コンソールの起動

PS.png

コマンド
Import-Module ServerManager
Add-WindowsFeature RSAT-AD-PowerShell,RSAT-AD-AdminCenter

管理ツールを起動

コマンド
C:\Windows\system32\dsa.msc /s

3. ユーザの作成

user01.png

user02.png

user03.png

補足

Linuxインスタンスをドメインに参加させる手順は以下のドキュメントを参照してください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0