sborenst
2017-09-14 b73980002c199aa6ca5b776f8296d97ba1455e45
added windows to ansible-tower-lab - wip
3 files modified
392 ■■■■■ changed files
ansible/configs/ans-tower-lab/env_vars.yml 18 ●●●● patch | view | raw | blame | history
ansible/configs/ans-tower-lab/files/cloud_providers/ec2_cloud_template.j2 329 ●●●●● patch | view | raw | blame | history
ansible/configs/ans-tower-lab/files/hosts_template.j2 45 ●●●● patch | view | raw | blame | history
ansible/configs/ans-tower-lab/env_vars.yml
@@ -69,16 +69,24 @@
## Environment Sizing
bastion_instance_type: "t2.medium" # (2 vCPU and 8GB Memory)
tower_instance_type: "t2.large" # (2 vCPU and 8GB Memory)
bastion_instance_type: "t2.medium"
tower_instance_type: "t2.large"
support_instance_type: "t2.medium"
internalhost_instance_type: "t2.small" # (2 vCPU and 8GB Memory)
support_instance_type: "t2.medium" # (2 vCPU and 4GB Memory)
frontend_instance_type: "t2.small"
app_instance_type: "{{frontend_instance_type}}"
appdb_instance_type: "{{frontend_instance_type}}"
internalhost_instance_count: 3
tower_instance_count: 3
support_instance_count: 2
frontend_instance_count: 1
app_instance_count: 2
appdb_instance_count: 1
windows_instance_type: "t2.large"
windows_instance_count: 1
###### VARIABLES YOU SHOULD ***NOT*** CONFIGURE FOR YOUR DEPLOYEMNT
ansible/configs/ans-tower-lab/files/cloud_providers/ec2_cloud_template.j2
@@ -4,40 +4,40 @@
  "Mappings": {
    "RegionMapping": {
      "us-east-1": {
        "AMI": "ami-b63769a1"
        "RHELAMI": "ami-b63769a1", "WIN2012R2AMI": "ami-7da4ab6b"
      },
      "us-east-2": {
        "AMI": "ami-0932686c"
        "RHELAMI": "ami-0932686c", "WIN2012R2AMI": "ami-ffae8f9a"
      },
      "us-west-1": {
        "AMI": "ami-2cade64c"
        "RHELAMI": "ami-2cade64c", "WIN2012R2AMI": "ami-a11836c1"
      },
      "us-west-2": {
        "AMI": "ami-6f68cf0f"
        "RHELAMI": "ami-6f68cf0f", "WIN2012R2AMI": "ami-a1c1ddd8"
      },
      "eu-west-1": {
        "AMI": "ami-02ace471"
        "RHELAMI": "ami-02ace471", "WIN2012R2AMI": "ami-cc8e98a8"
      },
      "eu-central-1": {
        "AMI": "ami-e4c63e8b"
        "RHELAMI": "ami-e4c63e8b", "WIN2012R2AMI": "ami-da1ebdb5"
      },
      "ap-northeast-1": {
        "AMI": "ami-5de0433c"
        "RHELAMI": "ami-5de0433c", "WIN2012R2AMI": "ami-4312cc2d"
      },
      "ap-northeast-2": {
        "AMI": "ami-44db152a"
        "RHELAMI": "ami-44db152a", "WIN2012R2AMI": "ami-68756f0f"
      },
      "ap-southeast-1": {
        "AMI": "ami-2c95344f"
        "RHELAMI": "ami-2c95344f", "WIN2012R2AMI": "ami-7644d315"
      },
      "ap-southeast-2": {
        "AMI": "ami-39ac915a"
        "RHELAMI": "ami-39ac915a", "WIN2012R2AMI": "ami-468f9225"
      },
      "sa-east-1": {
        "AMI": "ami-7de77b11"
        "RHELAMI": "ami-7de77b11", "WIN2012R2AMI": "ami-c8285ca4"
      },
      "ap-south-1": {
        "AMI": "ami-cdbdd7a2"
        "RHELAMI": "ami-cdbdd7a2", "WIN2012R2AMI": "ami-8eafd6e1"
      }
    },
    "DNSMapping": {
@@ -317,7 +317,7 @@
            {
              "Ref": "AWS::Region"
            },
            "AMI"
            "RHELAMI"
          ]
        },
        "InstanceType": "{{bastion_instance_type}}",
@@ -397,7 +397,7 @@
                {
                  "Ref": "AWS::Region"
                },
                "AMI"
                "RHELAMI"
              ]
            },
            "InstanceType": "{{tower_instance_type}}",
@@ -486,8 +486,188 @@
        {% endfor %}
    {% for c in range(1,(internalhost_instance_count|int)+1) %}
    "internalhost{{loop.index}}": {
        {% for c in range(1,(frontend_instance_count|int)+1) %}
        "frontend{{loop.index}}": {
          "Type": "AWS::EC2::Instance",
          "Properties": {
            "ImageId": {
              "Fn::FindInMap": [
                "RegionMapping",
                {
                  "Ref": "AWS::Region"
                },
                "RHELAMI"
              ]
            },
            "InstanceType": "{{frontend_instance_type}}",
            "KeyName": "{{key_name}}",
            "SecurityGroupIds": [
              {
                "Fn::GetAtt": [
                  "HostSG",
                  "GroupId"
                ]
              }
            ],
            "SubnetId": {
              "Ref": "PublicSubnet"
            },
            "Tags": [
              {
                "Key": "Name",
                "Value": "frontend{{loop.index}}"
              },
              {
                "Key": "AnsibleGroup",
                "Value": "frontends"
              },
              {
                "Key": "Project",
                "Value": "{{project_tag}}"
              },
              {
                "Key": "{{ project_tag }}",
                "Value": "frontend"
              },
              {
                "Key": "internaldns",
                "Value": "frontend{{loop.index}}.{{chomped_zone_internal_dns}}"
              }
            ],
            "BlockDeviceMappings": [
              {
                "DeviceName": "/dev/sda1",
                "Ebs": {
                  "VolumeSize": 50
                }
              },
              {
                "DeviceName": "/dev/xvdb",
                "Ebs": {
                  "VolumeType": "gp2",
                  "VolumeSize": 30
                }
              }
            ]
          }
        },
        "frontend{{loop.index}}DNS": {
          "Type": "AWS::Route53::RecordSetGroup",
          "Properties": {
          "HostedZoneId" : { "Ref" : "zoneinternalidns" },
            "RecordSets": [
              {
                "Name": "frontend{{loop.index}}.{{zone_internal_dns}}",
                "Type": "A",
                "TTL": "10",
                "ResourceRecords": [
                  {
                    "Fn::GetAtt": [
                      "frontend{{loop.index}}",
                      "PrivateIp"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {% endfor %}
        {% for c in range(1,(app_instance_count|int)+1) %}
        "app{{loop.index}}": {
          "Type": "AWS::EC2::Instance",
          "Properties": {
            "ImageId": {
              "Fn::FindInMap": [
                "RegionMapping",
                {
                  "Ref": "AWS::Region"
                },
                "RHELAMI"
              ]
            },
            "InstanceType": "{{app_instance_type}}",
            "KeyName": "{{key_name}}",
            "SecurityGroupIds": [
              {
                "Fn::GetAtt": [
                  "HostSG",
                  "GroupId"
                ]
              }
            ],
            "SubnetId": {
              "Ref": "PublicSubnet"
            },
            "Tags": [
              {
                "Key": "Name",
                "Value": "app{{loop.index}}"
              },
              {
                "Key": "AnsibleGroup",
                "Value": "apps"
              },
              {
                "Key": "Project",
                "Value": "{{project_tag}}"
              },
              {
                "Key": "{{ project_tag }}",
                "Value": "app"
              },
              {
                "Key": "internaldns",
                "Value": "app{{loop.index}}.{{chomped_zone_internal_dns}}"
              }
            ],
            "BlockDeviceMappings": [
              {
                "DeviceName": "/dev/sda1",
                "Ebs": {
                  "VolumeSize": 50
                }
              },
              {
                "DeviceName": "/dev/xvdb",
                "Ebs": {
                  "VolumeType": "gp2",
                  "VolumeSize": 30
                }
              }
            ]
          }
        },
        "app{{loop.index}}DNS": {
          "Type": "AWS::Route53::RecordSetGroup",
          "Properties": {
          "HostedZoneId" : { "Ref" : "zoneinternalidns" },
            "RecordSets": [
              {
                "Name": "app{{loop.index}}.{{zone_internal_dns}}",
                "Type": "A",
                "TTL": "10",
                "ResourceRecords": [
                  {
                    "Fn::GetAtt": [
                      "app{{loop.index}}",
                      "PrivateIp"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {% endfor %}
    {% for c in range(1,(appdb_instance_count|int)+1) %}
    "appdb{{loop.index}}": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId": {
@@ -496,10 +676,10 @@
            {
              "Ref": "AWS::Region"
            },
            "AMI"
            "RHELAMI"
          ]
        },
        "InstanceType": "{{internalhost_instance_type}}",
        "InstanceType": "{{appdb_instance_type}}",
        "KeyName": "{{key_name}}",
        "SecurityGroupIds": [
          {
@@ -515,11 +695,11 @@
        "Tags": [
          {
            "Key": "Name",
            "Value": "internalhost{{loop.index}}"
            "Value": "appdb{{loop.index}}"
          },
          {
            "Key": "AnsibleGroup",
            "Value": "internalhosts"
            "Value": "appdbs"
          },
          {
            "Key": "Project",
@@ -527,11 +707,11 @@
          },
          {
            "Key": "{{ project_tag }}",
            "Value": "internalhost"
            "Value": "appdb"
          },
          {
            "Key": "internaldns",
            "Value": "internalhost{{loop.index}}.{{chomped_zone_internal_dns}}"
            "Value": "appdb{{loop.index}}.{{chomped_zone_internal_dns}}"
          }
        ],
        "BlockDeviceMappings": [
@@ -553,20 +733,117 @@
    },
    "internalhost{{loop.index}}DNS": {
    "appdb{{loop.index}}DNS": {
      "Type": "AWS::Route53::RecordSetGroup",
      "Properties": {
      "HostedZoneId" : { "Ref" : "zoneinternalidns" },
        "RecordSets": [
          {
            "Name": "internalhost{{loop.index}}.{{zone_internal_dns}}",
            "Name": "appdb{{loop.index}}.{{zone_internal_dns}}",
            "Type": "A",
            "TTL": "10",
            "ResourceRecords": [
              {
                "Fn::GetAtt": [
                  "internalhost{{loop.index}}",
                  "appdb{{loop.index}}",
                  "PrivateIp"
                ]
              }
            ]
          }
        ]
      }
    },
    {% endfor %}
    {% for c in range(1,(windows_instance_count|int)+1) %}
    "windows{{loop.index}}": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId": {
          "Fn::FindInMap": [
            "RegionMapping",
            {
              "Ref": "AWS::Region"
            },
            "WIN2012R2AMI"
          ]
        },
        "InstanceType": "{{windows_instance_type}}",
        "KeyName": "{{key_name}}",
        "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
          "<powershell>\n",
          "$admin = [adsi](\"WinNT://./administrator, user\")\n",
          "$admin.PSBase.Invoke(\"SetPassword\", \"ansibletestpass123\")\n",
          "Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))\n",
          "</powershell>"
          ]]}},
        "SecurityGroupIds": [
          {
            "Fn::GetAtt": [
              "HostSG",
              "GroupId"
            ]
          }
        ],
        "SubnetId": {
          "Ref": "PublicSubnet"
        },
        "Tags": [
          {
            "Key": "Name",
            "Value": "windows{{loop.index}}"
          },
          {
            "Key": "AnsibleGroup",
            "Value": "windowss"
          },
          {
            "Key": "Project",
            "Value": "{{project_tag}}"
          },
          {
            "Key": "{{ project_tag }}",
            "Value": "windows"
          },
          {
            "Key": "internaldns",
            "Value": "windows{{loop.index}}.{{chomped_zone_internal_dns}}"
          }
        ],
        "BlockDeviceMappings": [
          {
            "DeviceName": "/dev/sda1",
            "Ebs": {
              "VolumeSize": 50
            }
          },
          {
            "DeviceName": "/dev/xvdb",
            "Ebs": {
              "VolumeType": "gp2",
              "VolumeSize": 30
            }
          }
        ]
      }
    },
    "windows{{loop.index}}DNS": {
      "Type": "AWS::Route53::RecordSetGroup",
      "Properties": {
      "HostedZoneId" : { "Ref" : "zoneinternalidns" },
        "RecordSets": [
          {
            "Name": "windows{{loop.index}}.{{zone_internal_dns}}",
            "Type": "A",
            "TTL": "10",
            "ResourceRecords": [
              {
                "Fn::GetAtt": [
                  "windows{{loop.index}}",
                  "PrivateIp"
                ]
              }
@@ -586,7 +863,7 @@
            {
              "Ref": "AWS::Region"
            },
            "AMI"
            "RHELAMI"
          ]
        },
        "InstanceType": "{{support_instance_type}}",
ansible/configs/ans-tower-lab/files/hosts_template.j2
@@ -10,8 +10,13 @@
[GenericExample:children]
towers
internalhosts
frontends
apps
appdbs
windows
support
[towers]
## These are the towers
@@ -19,14 +24,44 @@
tower{{loop.index}}.{{chomped_zone_internal_dns}} public_host_name=tower{{loop.index}}.{{ guid }}{{subdomain_base_suffix}} ssh_host={{host}}
{% endfor %}
[internalhosts]
## These are the internalhosts
{% for host in groups[('tag_' + project_tag + '_internalhost') | replace('-', '_') ] %}
internalhost{{loop.index}}.{{chomped_zone_internal_dns}} ssh_host={{host}}
[frontends]
## These are the frontends
{% for host in groups[('tag_' + project_tag + '_frontend') | replace('-', '_') ] %}
frontend{{loop.index}}.{{chomped_zone_internal_dns}} ssh_host={{host}}
{% endfor %}
[apps]
## These are the apps
{% for host in groups[('tag_' + project_tag + '_app') | replace('-', '_') ] %}
app{{loop.index}}.{{chomped_zone_internal_dns}} ssh_host={{host}}
{% endfor %}
[appdbs]
## These are the appdbs
{% for host in groups[('tag_' + project_tag + '_appdb') | replace('-', '_') ] %}
appdb{{loop.index}}.{{chomped_zone_internal_dns}} ssh_host={{host}}
{% endfor %}
[windows]
## These are the windows servers
{% for host in groups[('tag_' + project_tag + '_windows') | replace('-', '_') ] %}
windows{{loop.index}}.{{chomped_zone_internal_dns}} ssh_host={{host}}
{% endfor %}
## These are the supporthosts
[support]
{% for host in groups[('tag_' + project_tag + '_support') | replace('-', '_') ] %}
support{{loop.index}}.{{chomped_zone_internal_dns}} ssh_hose={{host}}
{% endfor %}
[windows:vars]
ansible_connection=winrm
ansible_ssh_port=5986
ansible_ssh_user=Administrator
ansible_ssh_pass=ansibletestpass123
ansible_winrm_server_cert_validation=ignore