parameters written as fully expanded YAML dictionaries

parent 411f0092
--- ---
# Creates a new ansible role # Creates a new ansible role
# Usage: # Usage:
# ansible-playbook ./create_django_ida.yml -i "localhost," -c local -e role_name=my_awesome_role # ansible-playbook ./create_django_ida.yml -i "localhost," -c local -e my_role_name=my_awesome_role
# #
- hosts: localhost - hosts: localhost
gather_facts: False gather_facts: False
......
--- ---
# Creates a new ansible role # Creates a new ansible role
# Usage: # Usage:
# ansible-playbook -c local --limit "localhost," ./create_role.yml -i "localhost," -e role_name=my_awesome_role # ansible-playbook -c local --limit "localhost," ./create_role.yml -i "localhost," -e my_role_name=my_awesome_role
# #
- hosts: localhost - hosts: localhost
gather_facts: False gather_facts: False
......
--- ---
- name: Check if the role exists
- name: check if the role exists stat:
stat: path=roles/{{ role_name }} path: "roles/{{ my_role_name }}"
register: role_exists register: role_exists
- name: prompt for overwrite - name: Prompt for overwrite
pause: prompt="Role {{ role_name }} exists. Overwrite? Touch any key to continue or <CTRL>-c, then a, to abort." pause: prompt="Role {{ my_role_name }} exists. Overwrite? Touch any key to continue or <CTRL>-c, then a, to abort."
when: role_exists.stat.exists when: role_exists.stat.exists
- name: create docker directories - name: Create docker directories
file: path=../docker/{{ item }}/{{ role_name }} state=directory file:
path: "../docker/{{ item }}/{{ my_role_name }}"
state: directory
with_items: with_items:
- build - build
- name: create role directories - name: Create role directories
file: path=roles/{{ role_name }}/{{ item }} state=directory file:
path: "roles/{{ my_role_name }}/{{ item }}"
state: directory
with_items: with_items:
- tasks - tasks
- meta - meta
- defaults - defaults
- templates/edx/app/supervisor/conf.d.available - templates/edx/app/supervisor/conf.d.available
- templates/edx/app/{{ role_name }} - templates/edx/app/{{ my_role_name }}
- templates/edx/app/nginx/sites-available - templates/edx/app/nginx/sites-available
- name: make an ansible role - name: Make an ansible role
template: src={{ item }}/main.yml.j2 dest=roles/{{ role_name }}/{{ item }}/main.yml template:
src: "{{ item }}/main.yml.j2"
dest: "roles/{{ my_role_name }}/{{ item }}/main.yml"
with_items: with_items:
- tasks - tasks
- meta - meta
- defaults - defaults
- name: update docker templates - name: Update docker templates
template: src=docker/{{ item.src }} dest=../docker/{{ item.dest }} template:
src: "docker/{{ item.src }}"
dest: "../docker/{{ item.dest }}"
with_items: with_items:
- { src: 'build/ROLE_NAME/Dockerfile.j2', dest: 'build/{{ role_name|replace("_","-") }}/Dockerfile'} - { src: 'build/ROLE_NAME/Dockerfile.j2', dest: 'build/{{ my_role_name|replace("_","-") }}/Dockerfile'}
- { src: 'build/ROLE_NAME/ansible_overrides.yml.j2', dest: 'build/{{ role_name|replace("_","-") }}/ansible_overrides.yml'} - { src: 'build/ROLE_NAME/ansible_overrides.yml.j2', dest: 'build/{{ my_role_name|replace("_","-") }}/ansible_overrides.yml'}
- { src: 'build/ROLE_NAME/inventory', dest: 'build/{{ role_name|replace("_","-") }}/inventory'} - { src: 'build/ROLE_NAME/inventory', dest: 'build/{{ my_role_name|replace("_","-") }}/inventory'}
- { src: 'plays/ROLE_NAME.yml.j2', dest: 'plays/{{ role_name }}.yml'} - { src: 'plays/ROLE_NAME.yml.j2', dest: 'plays/{{ my_role_name }}.yml'}
- name: update role templates - name: Update role templates
template: src=templates/{{ item.src }} dest=roles/{{ role_name }}/templates/{{ item.dest }} template:
src: "templates/{{ item.src }}"
dest: "roles/{{ my_role_name }}/templates/{{ item.dest }}"
with_items: with_items:
- { src: 'edx/app/supervisor/conf.d.available/ROLE_NAME.conf.j2', dest: 'edx/app/supervisor/conf.d.available/{{ role_name }}.conf.j2'} - { src: 'edx/app/supervisor/conf.d.available/ROLE_NAME.conf.j2', dest: 'edx/app/supervisor/conf.d.available/{{ my_role_name }}.conf.j2'}
- { src: 'edx/app/ROLE_NAME/ROLE_NAME.sh.j2', dest: 'edx/app/{{ role_name }}/{{ role_name }}.sh.j2'} - { src: 'edx/app/ROLE_NAME/ROLE_NAME.sh.j2', dest: 'edx/app/{{ my_role_name }}/{{ my_role_name }}.sh.j2'}
- { src: 'edx/app/ROLE_NAME/ROLE_NAME_env.j2', dest: 'edx/app/{{ role_name }}/{{ role_name }}_env.j2'} - { src: 'edx/app/ROLE_NAME/ROLE_NAME_env.j2', dest: 'edx/app/{{ my_role_name }}/{{ my_role_name }}_env.j2'}
- { src: 'edx/app/ROLE_NAME/ROLE_NAME_gunicorn.py.j2', dest: 'edx/app/{{ role_name }}/{{ role_name }}_gunicorn.py.j2'} - { src: 'edx/app/ROLE_NAME/ROLE_NAME_gunicorn.py.j2', dest: 'edx/app/{{ my_role_name }}/{{ my_role_name }}_gunicorn.py.j2'}
- { src: 'edx/app/ROLE_NAME/devstack.sh.j2', dest: 'edx/app/{{ role_name }}/devstack.sh.j2'} - { src: 'edx/app/ROLE_NAME/devstack.sh.j2', dest: 'edx/app/{{ my_role_name }}/devstack.sh.j2'}
- { src: 'edx/app/nginx/sites-available/ROLE_NAME.j2', dest: 'edx/app/nginx/sites-available/{{ role_name }}.j2'} - { src: 'edx/app/nginx/sites-available/ROLE_NAME.j2', dest: 'edx/app/nginx/sites-available/{{ my_role_name }}.j2'}
--- ---
- name: Check if the role exists
- name: check if the role exists command: "test -d roles/{{ my_role_name }}"
command: test -d roles/{{ role_name }}
register: role_exists register: role_exists
ignore_errors: yes ignore_errors: yes
- name: prompt for overwrite - name: Prompt for overwrite
pause: prompt="Role {{ role_name }} exists. Overwrite? Touch any key to continue or <CTRL>-c, then a, to abort." pause: prompt="Role {{ my_role_name }} exists. Overwrite? Touch any key to continue or <CTRL>-c, then a, to abort."
when: role_exists | success when: role_exists | success
- name: create role directories - name: Create role directories
file: path=roles/{{ role_name }}/{{ item }} state=directory file:
path: "roles/{{ my_role_name }}/{{ item }}"
state: directory
with_items: with_items:
- tasks - tasks
- meta - meta
...@@ -18,8 +19,10 @@ ...@@ -18,8 +19,10 @@
- templates - templates
- files - files
- name: make an ansible role - name: Make an ansible role
template: src={{ item }}/main.yml.j2 dest=roles/{{ role_name }}/{{ item }}/main.yml template:
src: "{{ item }}/main.yml.j2"
dest: "roles/{{ my_role_name }}/{{ item }}/main.yml"
with_items: with_items:
- tasks - tasks
- meta - meta
......
--- ---
- name: Dump all vars to json - name: Dump all vars to json
template: src=dumpall.json.j2 dest=/tmp/ansible.all.json mode=0600 template:
src: dumpall.json.j2
dest: /tmp/ansible.all.json
mode: 0600
tags: tags:
- dumpall - dumpall
- debug - debug
- name: Dump lms auth|env file - name: Dump lms auth|env file
template: src=../../edxapp/templates/lms.{{ item }}.json.j2 dest=/tmp/lms.{{ item }}.json mode=0600 template:
src: "../../edxapp/templates/lms.{{ item }}.json.j2"
dest: "/tmp/lms.{{ item }}.json"
mode: 0600
with_items: with_items:
- env - env
- auth - auth
...@@ -16,7 +22,10 @@ ...@@ -16,7 +22,10 @@
- debug - debug
- name: Dump lms-preview auth|env file - name: Dump lms-preview auth|env file
template: src=../../edxapp/templates/lms-preview.{{ item }}.json.j2 dest=/tmp/lms-preview.{{ item }}.json mode=0600 template:
src: "../../edxapp/templates/lms-preview.{{ item }}.json.j2"
dest: "/tmp/lms-preview.{{ item }}.json"
mode: 0600
with_items: with_items:
- env - env
- auth - auth
...@@ -26,7 +35,10 @@ ...@@ -26,7 +35,10 @@
- debug - debug
- name: Dump cms auth|env file - name: Dump cms auth|env file
template: src=../../edxapp/templates/cms.{{ item }}.json.j2 dest=/tmp/cms.{{ item }}.json mode=0600 template:
src: "../../edxapp/templates/cms.{{ item }}.json.j2"
dest: "/tmp/cms.{{ item }}.json"
mode: 0600
with_items: with_items:
- env - env
- auth - auth
...@@ -36,7 +48,10 @@ ...@@ -36,7 +48,10 @@
- debug - debug
- name: Dump all vars to yaml - name: Dump all vars to yaml
template: src=dumpall.yml.j2 dest=/tmp/ansible.all.yml mode=0600 template:
src: dumpall.yml.j2
dest: /tmp/ansible.all.yml
mode: 0600
tags: tags:
- dumpall - dumpall
- debug - debug
...@@ -44,7 +59,10 @@ ...@@ -44,7 +59,10 @@
- name: fetch remote files - name: fetch remote files
# fetch is fail-safe for remote files that don't exist # fetch is fail-safe for remote files that don't exist
# setting mode is not an option # setting mode is not an option
fetch: src=/tmp/{{ item }} dest=/tmp/{{ ansible_hostname }}-{{item}} flat=True fetch:
src: "/tmp/{{ item }}"
dest: "/tmp/{{ ansible_hostname }}-{{item}}"
flat: True
with_items: with_items:
- ansible.all.json - ansible.all.json
- ansible.all.yml - ansible.all.yml
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
# #
- name: update the termination date and time as motd - name: update the termination date and time as motd
template: > template:
dest=/etc/update-motd.d/999-terminate-sandbox dest: "/etc/update-motd.d/999-terminate-sandbox"
src=etc/update-motd.d/temiate_motd.j2 mode=0755 owner=root group=root src: "etc/update-motd.d/temiate_motd.j2"
mode: 0755
owner: root
group: root
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment