parameters written as fully expanded YAML dictionaries

parent 411f0092
---
# Creates a new ansible role
# 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
gather_facts: False
......
---
# Creates a new ansible role
# 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
gather_facts: False
......
---
- name: check if the role exists
stat: path=roles/{{ role_name }}
- name: Check if the role exists
stat:
path: "roles/{{ my_role_name }}"
register: role_exists
- name: prompt for overwrite
pause: prompt="Role {{ role_name }} exists. Overwrite? Touch any key to continue or <CTRL>-c, then a, to abort."
- name: Prompt for overwrite
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
- name: create docker directories
file: path=../docker/{{ item }}/{{ role_name }} state=directory
- name: Create docker directories
file:
path: "../docker/{{ item }}/{{ my_role_name }}"
state: directory
with_items:
- build
- name: create role directories
file: path=roles/{{ role_name }}/{{ item }} state=directory
- name: Create role directories
file:
path: "roles/{{ my_role_name }}/{{ item }}"
state: directory
with_items:
- tasks
- meta
- defaults
- templates/edx/app/supervisor/conf.d.available
- templates/edx/app/{{ role_name }}
- templates/edx/app/{{ my_role_name }}
- templates/edx/app/nginx/sites-available
- name: make an ansible role
template: src={{ item }}/main.yml.j2 dest=roles/{{ role_name }}/{{ item }}/main.yml
- name: Make an ansible role
template:
src: "{{ item }}/main.yml.j2"
dest: "roles/{{ my_role_name }}/{{ item }}/main.yml"
with_items:
- tasks
- meta
- defaults
- name: update docker templates
template: src=docker/{{ item.src }} dest=../docker/{{ item.dest }}
- name: Update docker templates
template:
src: "docker/{{ item.src }}"
dest: "../docker/{{ item.dest }}"
with_items:
- { src: 'build/ROLE_NAME/Dockerfile.j2', dest: 'build/{{ role_name|replace("_","-") }}/Dockerfile'}
- { src: 'build/ROLE_NAME/ansible_overrides.yml.j2', dest: 'build/{{ role_name|replace("_","-") }}/ansible_overrides.yml'}
- { src: 'build/ROLE_NAME/inventory', dest: 'build/{{ role_name|replace("_","-") }}/inventory'}
- { src: 'plays/ROLE_NAME.yml.j2', dest: 'plays/{{ role_name }}.yml'}
- { src: 'build/ROLE_NAME/Dockerfile.j2', dest: 'build/{{ my_role_name|replace("_","-") }}/Dockerfile'}
- { src: 'build/ROLE_NAME/ansible_overrides.yml.j2', dest: 'build/{{ my_role_name|replace("_","-") }}/ansible_overrides.yml'}
- { src: 'build/ROLE_NAME/inventory', dest: 'build/{{ my_role_name|replace("_","-") }}/inventory'}
- { src: 'plays/ROLE_NAME.yml.j2', dest: 'plays/{{ my_role_name }}.yml'}
- name: update role templates
template: src=templates/{{ item.src }} dest=roles/{{ role_name }}/templates/{{ item.dest }}
- name: Update role templates
template:
src: "templates/{{ item.src }}"
dest: "roles/{{ my_role_name }}/templates/{{ item.dest }}"
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/ROLE_NAME/ROLE_NAME.sh.j2', dest: 'edx/app/{{ role_name }}/{{ 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_gunicorn.py.j2', dest: 'edx/app/{{ role_name }}/{{ role_name }}_gunicorn.py.j2'}
- { src: 'edx/app/ROLE_NAME/devstack.sh.j2', dest: 'edx/app/{{ 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/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/{{ my_role_name }}/{{ my_role_name }}.sh.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/{{ my_role_name }}/{{ my_role_name }}_gunicorn.py.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/{{ my_role_name }}.j2'}
---
- name: check if the role exists
command: test -d roles/{{ role_name }}
---
- name: Check if the role exists
command: "test -d roles/{{ my_role_name }}"
register: role_exists
ignore_errors: yes
- name: prompt for overwrite
pause: prompt="Role {{ role_name }} exists. Overwrite? Touch any key to continue or <CTRL>-c, then a, to abort."
- name: Prompt for overwrite
pause: prompt="Role {{ my_role_name }} exists. Overwrite? Touch any key to continue or <CTRL>-c, then a, to abort."
when: role_exists | success
- name: create role directories
file: path=roles/{{ role_name }}/{{ item }} state=directory
- name: Create role directories
file:
path: "roles/{{ my_role_name }}/{{ item }}"
state: directory
with_items:
- tasks
- meta
......@@ -18,9 +19,11 @@
- templates
- files
- name: make an ansible role
template: src={{ item }}/main.yml.j2 dest=roles/{{ role_name }}/{{ item }}/main.yml
- name: Make an ansible role
template:
src: "{{ item }}/main.yml.j2"
dest: "roles/{{ my_role_name }}/{{ item }}/main.yml"
with_items:
- tasks
- meta
- defaults
- defaults
\ No newline at end of file
---
- 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:
- dumpall
- debug
- dumpall
- debug
- 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:
- env
- auth
when: "'lms' in service_variants_enabled"
tags:
- dumpall
- debug
- dumpall
- debug
- 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:
- env
- auth
when: "'lms-preview' in service_variants_enabled"
tags:
- dumpall
- debug
- dumpall
- debug
- 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:
- env
- auth
when: "'cms' in service_variants_enabled"
tags:
- dumpall
- debug
- dumpall
- debug
- 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:
- dumpall
- debug
- dumpall
- debug
- name: fetch remote files
# fetch is fail-safe for remote files that don't exist
# 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:
- ansible.all.json
- ansible.all.yml
......@@ -55,5 +73,5 @@
- cms.env.json
- cms.auth.json
tags:
- dumpall
- debug
- dumpall
- debug
......@@ -23,6 +23,9 @@
#
- name: update the termination date and time as motd
template: >
dest=/etc/update-motd.d/999-terminate-sandbox
src=etc/update-motd.d/temiate_motd.j2 mode=0755 owner=root group=root
template:
dest: "/etc/update-motd.d/999-terminate-sandbox"
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