From 8ca501cd938f77efbbff362258ec78ddaf20a1b0 Mon Sep 17 00:00:00 2001 From: "don.sizemore" Date: Tue, 7 Apr 2020 15:23:13 -0400 Subject: [PATCH 1/6] #164 initial commit --- defaults/main.yml | 11 ++++++ tasks/localstack.yml | 58 +++++++++++++++++++++++++++++ tasks/main.yml | 4 ++ templates/daemon.json.j2 | 3 ++ templates/localstack-compose.yml.j2 | 20 ++++++++++ 5 files changed, 96 insertions(+) create mode 100644 tasks/localstack.yml create mode 100644 templates/daemon.json.j2 create mode 100644 templates/localstack-compose.yml.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 67631d6..5d2eb18 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -138,6 +138,17 @@ grafana: grafana_user: 'admin' grafana_password: 'admin' +localstack: + enabled: true + docker: + cidr: '192.168.77.0/24' + repo: https://download.docker.com/linux/centos/docker-ce.repo + container: 's3-test' + data_dir: /tmp/localstack/data + debug: true + hostname_external: + web_ui: 8888 + munin: install: false admin: diff --git a/tasks/localstack.yml b/tasks/localstack.yml new file mode 100644 index 0000000..7b1bc64 --- /dev/null +++ b/tasks/localstack.yml @@ -0,0 +1,58 @@ +--- + +- name: install docker-ce repo + yum: + name: '{{ localstack.docker.repo }}' + state: latest + +- name: install docker-ce + yum: + name: ['docker-ce','docker-ce-cli','containerd.io','docker-compose'] + +- name: configure cidr range + template: + src: daemon.json.j2 + dest: /etc/docker/daemon.json + owner: root + group: root + mode: 0644 + +- 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 + +- name: ensure python3 + yum: + name: ['python3','python3-pip'] + state: latest + +- name: install localstack + pip: + name: localstack + executable: pip3 + +# 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 | length == 0 + +- name: place docker-compose.yml template + template: + src: localstack-compose.yml.j2 + dest: '{{ ansible_env.HOME }}/localstack-compose.yml' + +- name: start s3-test container + docker-compose: + files: '{{ ansible_env.HOME }}/localstack-compose.yml' diff --git a/tasks/main.yml b/tasks/main.yml index ac2a01c..24782e2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -52,6 +52,10 @@ - include: solr.yml tags: solr +- include: localstack.yml + when: localstack.enabled == true + tags: localstack + - include: dataverse-install.yml tags: dataverse diff --git a/templates/daemon.json.j2 b/templates/daemon.json.j2 new file mode 100644 index 0000000..7dd357c --- /dev/null +++ b/templates/daemon.json.j2 @@ -0,0 +1,3 @@ +{ + "bip" : "{{ localstack.docker.cidr }}" +} diff --git a/templates/localstack-compose.yml.j2 b/templates/localstack-compose.yml.j2 new file mode 100644 index 0000000..01f7656 --- /dev/null +++ b/templates/localstack-compose.yml.j2 @@ -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: + - "${TMPDIR:-/tmp/localstack}:/tmp/localstack" + - "/var/run/docker.sock:/var/run/docker.sock" From 139552ca74763d61245cf1eb14d5eae7c9978fa9 Mon Sep 17 00:00:00 2001 From: "don.sizemore" Date: Tue, 7 Apr 2020 15:33:35 -0400 Subject: [PATCH 2/6] #164 state: present isn't implied --- tasks/localstack.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/localstack.yml b/tasks/localstack.yml index 7b1bc64..de46652 100644 --- a/tasks/localstack.yml +++ b/tasks/localstack.yml @@ -56,3 +56,4 @@ - name: start s3-test container docker-compose: files: '{{ ansible_env.HOME }}/localstack-compose.yml' + state: present From 1e64b7476d949dd7d86f426b28613f67e9a3db67 Mon Sep 17 00:00:00 2001 From: "don.sizemore" Date: Tue, 7 Apr 2020 16:56:07 -0400 Subject: [PATCH 3/6] #164 clean up initial run --- tasks/localstack.yml | 36 +++++++++++++++-------------- templates/localstack-compose.yml.j2 | 4 ++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/tasks/localstack.yml b/tasks/localstack.yml index de46652..6070e3f 100644 --- a/tasks/localstack.yml +++ b/tasks/localstack.yml @@ -1,13 +1,24 @@ --- -- name: install docker-ce repo +- name: we need yum-utils yum: - name: '{{ localstack.docker.repo }}' + 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'] + 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: @@ -16,6 +27,7 @@ owner: root group: root mode: 0644 + when: localstack.docker.cidr is undefined - name: add ansible_user to docker group user: @@ -30,23 +42,13 @@ daemon_reload: yes state: started -- name: ensure python3 - yum: - name: ['python3','python3-pip'] - state: latest - -- name: install localstack - pip: - name: localstack - executable: pip3 - # 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 | length == 0 + when: localstack.hostname_external is undefined - name: place docker-compose.yml template template: @@ -54,6 +56,6 @@ dest: '{{ ansible_env.HOME }}/localstack-compose.yml' - name: start s3-test container - docker-compose: - files: '{{ ansible_env.HOME }}/localstack-compose.yml' - state: present + shell: 'docker-compose -f localstack-compose.yml up -d' + args: + chdir: '{{ ansible_env.HOME }}' diff --git a/templates/localstack-compose.yml.j2 b/templates/localstack-compose.yml.j2 index 01f7656..d4627fa 100644 --- a/templates/localstack-compose.yml.j2 +++ b/templates/localstack-compose.yml.j2 @@ -9,12 +9,12 @@ services: - "{{ localstack.web_ui }}-{{ localstack.web_ui }}:{{ localstack.web_ui }}-{{ localstack.web_ui }}" environment: - SERVICES=s3 - - DEBUG={{ localstack.debug }}' + - 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: - - "${TMPDIR:-/tmp/localstack}:/tmp/localstack" + - "/tmp/localstack}:/tmp/localstack" - "/var/run/docker.sock:/var/run/docker.sock" From 0fcc34965706ca30fe50dc80416222987c26f803 Mon Sep 17 00:00:00 2001 From: "don.sizemore" Date: Tue, 7 Apr 2020 16:59:07 -0400 Subject: [PATCH 4/6] #164 add localstack group_var stanza to jenkins config --- tests/group_vars/jenkins.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/group_vars/jenkins.yml b/tests/group_vars/jenkins.yml index 6013f56..a6630c3 100644 --- a/tests/group_vars/jenkins.yml +++ b/tests/group_vars/jenkins.yml @@ -134,6 +134,17 @@ grafana: grafana_user: 'admin' grafana_password: 'adm1n' +localstack: + enabled: true + docker: + cidr: + repo: https://download.docker.com/linux/centos/docker-ce.repo + container: 's3-test' + data_dir: /tmp/localstack/data + debug: true + hostname_external: + web_ui: 8888 + munin: install: false admin: From 1bfa2bee51cf21a716f93e7e54ec0bd89829b210 Mon Sep 17 00:00:00 2001 From: "don.sizemore" Date: Thu, 9 Apr 2020 11:14:31 -0400 Subject: [PATCH 5/6] #164 disable by default --- defaults/main.yml | 4 ++-- tests/group_vars/jenkins.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 5d2eb18..c2b5427 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -139,9 +139,9 @@ grafana: grafana_password: 'admin' localstack: - enabled: true + enabled: false docker: - cidr: '192.168.77.0/24' + cidr: repo: https://download.docker.com/linux/centos/docker-ce.repo container: 's3-test' data_dir: /tmp/localstack/data diff --git a/tests/group_vars/jenkins.yml b/tests/group_vars/jenkins.yml index a6630c3..a62ca6f 100644 --- a/tests/group_vars/jenkins.yml +++ b/tests/group_vars/jenkins.yml @@ -135,7 +135,7 @@ grafana: grafana_password: 'adm1n' localstack: - enabled: true + enabled: false docker: cidr: repo: https://download.docker.com/linux/centos/docker-ce.repo From c6899933b189a0b3157eed83234ed407c3664673 Mon Sep 17 00:00:00 2001 From: "don.sizemore" Date: Thu, 9 Apr 2020 14:01:18 -0400 Subject: [PATCH 6/6] #164 leave persistence disabled per default --- defaults/main.yml | 3 ++- tests/group_vars/jenkins.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index c2b5427..a9ffd66 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -144,7 +144,8 @@ localstack: cidr: repo: https://download.docker.com/linux/centos/docker-ce.repo container: 's3-test' - data_dir: /tmp/localstack/data + # set to /tmp/localstack/data to enable persistence + data_dir: debug: true hostname_external: web_ui: 8888 diff --git a/tests/group_vars/jenkins.yml b/tests/group_vars/jenkins.yml index a62ca6f..d73ffe2 100644 --- a/tests/group_vars/jenkins.yml +++ b/tests/group_vars/jenkins.yml @@ -140,7 +140,8 @@ localstack: cidr: repo: https://download.docker.com/linux/centos/docker-ce.repo container: 's3-test' - data_dir: /tmp/localstack/data + # set to /tmp/localstack/data to enable persistence + data_dir: debug: true hostname_external: web_ui: 8888