Skip to content

Commit

Permalink
Merge pull request #165 from IQSS/164_localstack
Browse files Browse the repository at this point in the history
basic localstack framework
  • Loading branch information
donsizemore authored Apr 13, 2020
2 parents 6f60089 + c689993 commit 2fa5807
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 0 deletions.
12 changes: 12 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ grafana:
grafana_user: 'admin'
grafana_password: 'admin'

localstack:
enabled: false
docker:
cidr:
repo: https://download.docker.com/linux/centos/docker-ce.repo
container: 's3-test'
# set to /tmp/localstack/data to enable persistence
data_dir:
debug: true
hostname_external:
web_ui: 8888

munin:
install: false
admin:
Expand Down
61 changes: 61 additions & 0 deletions tasks/localstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---

- name: we need yum-utils
yum:
name: yum-utils
state: latest

- name: to install the docker-ce repo
shell: 'yum-config-manager --add-repo {{ localstack.docker.repo }}'

- name: install docker-ce
yum:
name: ['docker-ce','docker-ce-cli','containerd.io','docker-compose','python-docker-py']

- name: ensure /etc/docker exists
file:
path: /etc/docker
state: directory
owner: root
group: root
mode: 0755

- name: configure cidr range
template:
src: daemon.json.j2
dest: /etc/docker/daemon.json
owner: root
group: root
mode: 0644
when: localstack.docker.cidr is undefined

- name: add ansible_user to docker group
user:
name: '{{ ansible_user }}'
groups: docker
append: yes

- name: reload systemd, enable docker, start
systemd:
name: docker
enabled: yes
daemon_reload: yes
state: started

# so we can run localstack task stand-alone
- include: dataverse-fqdn.yml

- name: is hostname_external set
set_fact:
hostname_external: '{{ public_hostname }}'
when: localstack.hostname_external is undefined

- name: place docker-compose.yml template
template:
src: localstack-compose.yml.j2
dest: '{{ ansible_env.HOME }}/localstack-compose.yml'

- name: start s3-test container
shell: 'docker-compose -f localstack-compose.yml up -d'
args:
chdir: '{{ ansible_env.HOME }}'
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
- include: solr.yml
tags: solr

- include: localstack.yml
when: localstack.enabled == true
tags: localstack

- include: dataverse-install.yml
tags: dataverse

Expand Down
3 changes: 3 additions & 0 deletions templates/daemon.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bip" : "{{ localstack.docker.cidr }}"
}
20 changes: 20 additions & 0 deletions templates/localstack-compose.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '2.1'

services:
localstack:
container_name: "{{ localstack.container }}"
image: localstack/localstack
ports:
- "4567-4599:4567-4599"
- "{{ localstack.web_ui }}-{{ localstack.web_ui }}:{{ localstack.web_ui }}-{{ localstack.web_ui }}"
environment:
- SERVICES=s3
- DEBUG={{ localstack.debug }}
- DATA_DIR={{ localstack.data_dir }}
- PORT_WEB_UI={{ localstack.web_ui }}
- LOCALSTACK_HOSTNAME={{ localstack.hostname_external }}
- LAMBDA_EXECUTOR=local
- DOCKER_HOST=unix:///var/run/docker.sock
volumes:
- "/tmp/localstack}:/tmp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
12 changes: 12 additions & 0 deletions tests/group_vars/jenkins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ grafana:
grafana_user: 'admin'
grafana_password: 'adm1n'

localstack:
enabled: false
docker:
cidr:
repo: https://download.docker.com/linux/centos/docker-ce.repo
container: 's3-test'
# set to /tmp/localstack/data to enable persistence
data_dir:
debug: true
hostname_external:
web_ui: 8888

munin:
install: false
admin:
Expand Down

0 comments on commit 2fa5807

Please sign in to comment.