Skip to content

Commit

Permalink
deploy petstore on ECS
Browse files Browse the repository at this point in the history
  • Loading branch information
lixue323 committed Feb 28, 2020
1 parent 8dc527a commit a74a8da
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
8 changes: 4 additions & 4 deletions contrib/inventory/alicloud.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# Alicloud regions to make calls to. Set this to 'all' to make request to all regions
# in Alicloud and then merge the results together. Alternatively, set this to a comma
# separated list of regions. For example, regions = cn-beijing,eu-central-1,ap-southeast-1,us-east-1
regions = all
#regions = cn-beijing
# regions = all
regions = cn-beijing

# In addition, set 'regions_exclude' to a comma separated list of regions to filter 'all' regions.
#regions_exclude = us-west-1,ap-northeast-1
Expand All @@ -29,7 +29,7 @@ destination_variable = public_ip_address
# will still use destination_variable.
# WARNING: ECS server attribute 'tags' should be written as 'tag_TAGNAME',
# E.g. hostname_variable = tag_my-ansible
hostname_variable = instance_id
#hostname_variable = instance_id


# By default, only ECS instances in the 'running' status are returned.
Expand Down Expand Up @@ -92,7 +92,7 @@ group_by_tag_none = True
# a list separated by commas. See examples below.

# Retrieve only instances with (key=value) tool=ansible tag
# instance_filters = tag:tool=ansible
instance_filters = tag:For=PetStore
# Retrieve ecs.n4.small instances AND instances with tag tool=ansible
# instance_filters = instance_type=ecs.n4.small, tag:tool=ansible

Expand Down
13 changes: 13 additions & 0 deletions tests/ali_petstore_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Create ECS
hosts: localhost
remote_user: root
vars:
tags: {For: PetStore, Created: Ansible, From: provider/tests}
name: 'Instance_From_Ansible_Petstore'
count: 1
roles:
- vpc
- vswitch
- security_group
- instance
52 changes: 52 additions & 0 deletions tests/ali_petstore_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
- name: Deploy petstore on ECS
hosts: alicloud
remote_user: root

tasks:
- name: create property file
shell: "{{item}}"
with_items:
- echo "petstore.loggingLevel = warn" >> /root/antx.properties
- echo "petstore.loggingRoot = /root/pet/logs" >> /root/antx.properties
- echo "petstore.upload = /root/pet/upload" >> /root/antx.properties
- echo "petstore.work = /root/pet" >> /root/antx.properties

- name: remove java11
apt:
pkg:
- openjdk-11-jre-headless
- openjdk-11-jdk
state: absent
force_apt_get: True

- name: build enviroment
apt:
pkg:
- apache2
- openjdk-8-jre-headless
- openjdk-8-jdk
- git
- maven
force_apt_get: True

- name: clone project
command: "{{item}}"
with_items:
- git clone https://github.com/webx/citrus-sample.git

- name: mvn install
command: "{{item}}"
args:
chdir: /root/citrus-sample/petstore
with_items:
- mvn clean install

- name: run project
shell:
cmd: nohup mvn jetty:run-war &
chdir: /root/citrus-sample/petstore/web
register: petstore

- debug:
msg: http://{{hostvars[inventory_hostname]['public_ip_address']}}:8081?home
9 changes: 7 additions & 2 deletions tests/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ group_inboundRules:
source_cidr_ip: 0.0.0.0/0
priority: 1

- ip_protocol: tcp
port_range: 8081/8081
source_cidr_ip: 0.0.0.0/0
priority: 1

- ip_protocol: udp
port_range: 10988/10989
source_cidr_ip: 47.89.23.33/32
Expand All @@ -50,7 +55,7 @@ group_outboundRules:

# create ECS instance parameters
image_id: "ubuntu_18_04_64_20G_alibase_20190624.vhd"
instance_type: ecs.sn1ne.xlarge
instance_type: ecs.g5.large
instance_description: "Create a new ECS instance resource via Ansible example alicloud-ecs-vpc."
host_name: "my-instance-from-ansible"
password: "Test12345"
Expand All @@ -63,7 +68,7 @@ max_bandwidth_out: 50
system_disk_category: "cloud_ssd"
system_disk_size: 50

number_of_instances: 2
number_of_instances: 1
ram_role_name: ansible-test-vpc

spot_price_limit: 0.97
Expand Down

0 comments on commit a74a8da

Please sign in to comment.