-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Mahito/refact_playbooks
[refactor] openstack playbook refactoring
- Loading branch information
Showing
8 changed files
with
163 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
- name: ansible_python_interpreter setup | ||
set_fact: ansible_python_interpreter="{{ lookup('pipe', 'which python') }}" | ||
|
||
- name: get uuid for generate hostname | ||
command: /usr/bin/uuidgen | ||
register: result_uuid | ||
when: target in ["web", "app", "dbs"] | ||
|
||
- name: create {{ target }}-server on nova-compute with floating_ip | ||
nova_compute: | ||
state: present | ||
auth_url: "{{ auth.url }}" | ||
region_name: "{{ auth.region_name }}" | ||
login_tenant_name: "{{ auth.tenant_name }}" | ||
login_username: "{{ auth.username }}" | ||
login_password: "{{ auth.password }}" | ||
availability_zone: "{{ spec[target].availability_zone }}" | ||
flavor_ram: "{{ spec[target].flavor_ram }}" | ||
flavor_include: "{{ spec[target].flavor_name }}" | ||
floating_ip_pools: "{{ networks.os_ext_net_list }}" | ||
image_name: "{{ spec[target].image_name }}" | ||
key_name: "{{ spec[target].key_name }}" | ||
name: "{{ target }}-{{ result_uuid.stdout }}" | ||
nics: "{{ spec[target].networks }}" | ||
security_groups: "{{ spec[target].secgroups }}" | ||
when: (target == "web") and (spec[target].floating_ip) | ||
|
||
- name: create {{ target }}-server on nova-compute without floating_ip | ||
nova_compute: | ||
state: present | ||
auth_url: "{{ auth.url }}" | ||
region_name: "{{ auth.region_name }}" | ||
login_tenant_name: "{{ auth.tenant_name }}" | ||
login_username: "{{ auth.username }}" | ||
login_password: "{{ auth.password }}" | ||
availability_zone: "{{ spec[target].availability_zone }}" | ||
flavor_ram: "{{ spec[target].flavor_ram }}" | ||
flavor_include: "{{ spec[target].flavor_name }}" | ||
image_name: "{{ spec[target].image_name }}" | ||
key_name: "{{ spec[target].key_name }}" | ||
name: "{{ target }}-{{ result_uuid.stdout }}" | ||
nics: "{{ spec[target].networks }}" | ||
security_groups: "{{ spec[target].secgroups }}" | ||
when: (target in ["app","dbs"]) and (not spec[target].floating_ip) | ||
# | ||
# [EOF] | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
auth: | ||
url: "{{ lookup('env', 'OS_AUTH_URL') }}" | ||
region_name: "{{ lookup('env', 'OS_REGION_NAME') }}" | ||
tenant_name: "{{ lookup('env', 'OS_TENANT_NAME') }}" | ||
username: "{{ lookup('env', 'OS_USERNAME') }}" | ||
password: "{{ lookup('env', 'OS_PASSWORD') }}" | ||
networks: | ||
os_dmz_net: "{{ lookup('env', 'OS_DMZ_NET') }}" | ||
os_app_net: "{{ lookup('env', 'OS_APP_NET') }}" | ||
os_dbs_net: "{{ lookup('env', 'OS_DBS_NET') }}" | ||
os_ext_net_list: | ||
- "Ext-Net" | ||
spec: | ||
web: | ||
flavor_ram: 1024 | ||
flavor_name: "standard.xsmall" | ||
image_name: "centos-base" | ||
key_name: "key-for-internal" | ||
secgroups: "sg-all-from-console,sg-web-from-internet,sg-all-from-app-net" | ||
availability_zone: "az1" | ||
networks: | ||
- net-id: "{{ networks.os_dmz_net }}" | ||
- net-id: "{{ networks.os_app_net }}" | ||
floating_ip: yes | ||
app: | ||
flavor_ram: 1024 | ||
flavor_name: "standard.xsmall" | ||
image_name: "centos-base" | ||
key_name: "key-for-internal" | ||
secgroups: "sg-all-from-console,sg-all-from-app-net,sg-all-from-dbs-net" | ||
availability_zone: "az1" | ||
networks: | ||
- net-id: "{{ networks.os_dmz_net }}" | ||
- net-id: "{{ networks.os_app_net }}" | ||
- net-id: "{{ networks.os_dbs_net }}" | ||
floating_ip: no | ||
dbs: | ||
flavor_ram: 1024 | ||
flavor_name: "standard.xsmall" | ||
image_name: "centos-base" | ||
key_name: "key-for-internal" | ||
secgroups: "sg-all-from-console,sg-all-from-dbs-net" | ||
availability_zone: "az1" | ||
networks: | ||
- net-id: "{{ networks.os_dmz_net }}" | ||
- net-id: "{{ networks.os_dbs_net }}" | ||
floating_ip: no | ||
|
||
# | ||
# [EOF] | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- name: startup service | ||
shell: nohup /bin/bash /root/{{ spec[target].app_name }}/server-setup/{{ spec[target].startup_script }} start | ||
|
||
# | ||
# [EOF] | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: change the timezone | ||
command: cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime | ||
when: target in ["web", "app", "dbs"] | ||
|
||
- name: checkout app from github | ||
git: | ||
repo: "{{ spec[target].project_url }}" | ||
version: "{{ spec[target].init_script_version }}" | ||
dest: /root/{{ spec[target].app_name }} | ||
when: target in ["web", "app", "dbs"] | ||
|
||
- name: execute install script | ||
raw: sh /root/{{ spec[target].app_name }}/server-setup/{{ spec[target].init_script }} | ||
when: target in ["web", "app", "dbs"] | ||
|
||
- name: copy endpoint.conf to web and app server | ||
template: | ||
src: endpoint.conf.j2 | ||
dest: /root/{{ spec[target].app_name }}/endpoint.conf | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: startup service | ||
when: target in ["web", "app"] | ||
|
||
# | ||
# [EOF] | ||
# |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
spec: | ||
web: | ||
app_name: "sample-app" | ||
project_url: "https://github.com/josug-book1-materials/sample-app.git" | ||
init_script: "install_web.sh" | ||
startup_script: "web.init.sh" | ||
init_script_version: "v1.0" | ||
app: | ||
app_name: "sample-app" | ||
project_url: "https://github.com/josug-book1-materials/sample-app.git" | ||
init_script: "install_rest.sh" | ||
startup_script: "rest.init.sh" | ||
init_script_version: "v1.0" | ||
dbs: | ||
app_name: "sample-app" | ||
project_url: "https://github.com/josug-book1-materials/sample-app.git" | ||
init_script: "install_db.sh" | ||
init_script_version: "v1.0" | ||
|
||
# | ||
# [EOF] | ||
# |