Skip to content

Commit

Permalink
Merge pull request #16 from trento-project/add-indent-rule-yamllint
Browse files Browse the repository at this point in the history
Add indent rule yamllint
  • Loading branch information
rtorrero authored Jan 16, 2024
2 parents c8bc9f7 + b07c847 commit 09078e7
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 218 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
exclude_paths:
- .github/
skip_list:
- yaml[line-length]
3 changes: 3 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules:
indentation:
spaces: 2
32 changes: 16 additions & 16 deletions playbook.cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
hosts: trento-server
become: true
tasks:
- name: Containers
ansible.builtin.include_role:
name: containers
tasks_from: cleanup
- name: Proxy
ansible.builtin.include_role:
name: proxy
tasks_from: cleanup
- name: Containers
ansible.builtin.include_role:
name: containers
tasks_from: cleanup
- name: Proxy
ansible.builtin.include_role:
name: proxy
tasks_from: cleanup

- name: Clean up postgres
hosts: postgres-hosts
become: true
tasks:
- name: Postgres
ansible.builtin.include_role:
name: postgres
tasks_from: cleanup
- name: Postgres
ansible.builtin.include_role:
name: postgres
tasks_from: cleanup

- name: Clean up rabbitmq
hosts: rabbitmq-hosts
become: true
tasks:
- name: Rabbitmq
ansible.builtin.include_role:
name: rabbitmq
tasks_from: cleanup
- name: Rabbitmq
ansible.builtin.include_role:
name: rabbitmq
tasks_from: cleanup
100 changes: 50 additions & 50 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,87 +4,87 @@
hosts: trento-server
become: true
pre_tasks:
- name: Check SLES distribution and version
ansible.builtin.fail:
msg: "This playbook only runs on SLES for SAP 15 SP3 or above. Detected: {{ ansible_distribution }} {{ ansible_distribution_version }}"
when: >
((ansible_distribution != "SLES_SAP") and
(ansible_distribution != "openSUSE Leap")) or
(ansible_distribution_version is version('15.3', '<'))
- name: Check SLES distribution and version
ansible.builtin.fail:
msg: "This playbook only runs on SLES for SAP 15 SP3 or above. Detected: {{ ansible_distribution }} {{ ansible_distribution_version }}"
when: >
((ansible_distribution != "SLES_SAP") and
(ansible_distribution != "openSUSE Leap")) or
(ansible_distribution_version is version('15.3', '<'))
tasks:
- name: Install installation prerequisites
community.general.zypper:
name:
- gcc
- python3-devel
- sudo
- name: Install installation prerequisites
community.general.zypper:
name:
- gcc
- python3-devel
- sudo

- name: Install python prerequisites
community.general.zypper:
name:
- python3-setuptools
- python3-pip
- python3-pexpect
state: present
update_cache: true
- name: Install python prerequisites
community.general.zypper:
name:
- python3-setuptools
- python3-pip
- python3-pexpect
state: present
update_cache: true

- name: Install docker
community.general.zypper:
name: docker
state: present
update_cache: true
- name: Install docker
community.general.zypper:
name: docker
state: present
update_cache: true

- name: Start docker service
ansible.builtin.service:
name: docker
state: started
enabled: true
- name: Start docker service
ansible.builtin.service:
name: docker
state: started
enabled: true

- name: Provision postgres
become: true
vars:
provision_postgres: "true"
provision_postgres: "true"
hosts: postgres-hosts
roles:
- role: postgres
when: provision_postgres == 'true'
become: true
- role: postgres
when: provision_postgres == 'true'
become: true

- name: Provision prometheus
become: true
vars:
provision_prometheus: "true"
provision_prometheus: "true"
hosts: prometheus-hosts
roles:
- role: prometheus
when: provision_prometheus == 'true'
become: true
- role: prometheus
when: provision_prometheus == 'true'
become: true

- name: Provision rabbitmq
become: true
vars:
provision_rabbitmq: "true"
provision_rabbitmq: "true"
hosts: rabbitmq-hosts
roles:
- role: rabbitmq
when: provision_rabbitmq == 'true'
- role: rabbitmq
when: provision_rabbitmq == 'true'

- name: Configure trento projects
vars:
provision_proxy: "true"
provision_proxy: "true"
hosts: trento-server
become: true
roles:
- role: containers
become: true
- role: proxy
when: provision_proxy == 'true'
become: true
- role: containers
become: true
- role: proxy
when: provision_proxy == 'true'
become: true

- name: Configure trento agents
hosts: agents
become: true
roles:
- role: agent
become: true
- role: agent
become: true
4 changes: 2 additions & 2 deletions roles/agent/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
---
- name: Restart Trento agent
ansible.builtin.service:
name: trento-agent
state: restarted
name: trento-agent
state: restarted
1 change: 0 additions & 1 deletion roles/agent/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# code: language=ansible
---

- name: Add Trento agent repository
community.general.zypper_repository:
name: trento
Expand Down
129 changes: 69 additions & 60 deletions roles/containers/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,86 @@
---
- name: Install docker python management deps
ansible.builtin.pip:
name:
- docker
state: present
name:
- docker
state: present

- name: Force pull trento images
when: force_pull_images == 'true'
loop:
- "{{ wanda_container_image }}"
- "{{ web_container_image }}"
- "{{ wanda_container_image }}"
- "{{ web_container_image }}"
community.docker.docker_image:
name: "{{ item }}"
force_source: true
source: pull

name: "{{ item }}"
force_source: true
source: pull

- name: Create trento docker network
community.docker.docker_network:
name: "{{ docker_network_name }}"
name: "{{ docker_network_name }}"

- name: Wanda container
community.docker.docker_container:
name: "{{ wanda_container_name }}"
state: started
restart_policy: unless-stopped
recreate: "{{ force_recreate_wanda_container == 'true' }}"
networks:
- name: "{{ docker_network_name }}"
image: "{{ wanda_container_image }}"
pull: true
entrypoint: ["/bin/sh", "-c", "/app/bin/wanda eval \"Wanda.Release.init()\" && /app/bin/wanda start"]
etc_hosts:
host.docker.internal: "host-gateway"
ports:
- "{{ wanda_container_port }}:4000"
env:
CORS_ORIGIN: "http://localhost" # TODO: Remove placeholder
SECRET_KEY_BASE: "{{ secret_key_base }}"
ACCESS_TOKEN_ENC_SECRET: "{{ access_token_secret }}"
AMQP_URL: "{{ amqp_protocol }}://{{ rabbitmq_username }}:{{ rabbitmq_password }}@{{ rabbitmq_host }}/{{ rabbitmq_vhost | urlencode | replace('/', '%2F') }}"
DATABASE_URL: "ecto://{{ wanda_postgres_user }}:{{ wanda_postgres_password }}@{{ wanda_postgres_host }}/{{ wanda_postgres_db }}"
name: "{{ wanda_container_name }}"
state: started
restart_policy: unless-stopped
recreate: "{{ force_recreate_wanda_container == 'true' }}"
networks:
- name: "{{ docker_network_name }}"
image: "{{ wanda_container_image }}"
pull: true
entrypoint:
[
"/bin/sh",
"-c",
'/app/bin/wanda eval "Wanda.Release.init()" && /app/bin/wanda start',
]
etc_hosts:
host.docker.internal: "host-gateway"
ports:
- "{{ wanda_container_port }}:4000"
env:
CORS_ORIGIN: "http://localhost" # TODO: Remove placeholder
SECRET_KEY_BASE: "{{ secret_key_base }}"
ACCESS_TOKEN_ENC_SECRET: "{{ access_token_secret }}"
AMQP_URL: "{{ amqp_protocol }}://{{ rabbitmq_username }}:{{ rabbitmq_password }}@{{ rabbitmq_host }}/{{ rabbitmq_vhost | urlencode | replace('/', '%2F') }}"
DATABASE_URL: "ecto://{{ wanda_postgres_user }}:{{ wanda_postgres_password }}@{{ wanda_postgres_host }}/{{ wanda_postgres_db }}"

- name: Web container
community.docker.docker_container:
name: "{{ web_container_name }}"
state: started
recreate: "{{ force_recreate_web_container == 'true' }}"
restart_policy: unless-stopped
image: "{{ web_container_image }}"
pull: true
networks:
- name: "{{ docker_network_name }}"
entrypoint: ["/bin/sh", "-c", "/app/bin/trento eval \"Trento.Release.init()\" && /app/bin/trento start"]
etc_hosts:
host.docker.internal: "host-gateway"
ports:
- "{{ web_container_port }}:4000"
env:
AMQP_URL: "{{ amqp_protocol }}://{{ rabbitmq_username }}:{{ rabbitmq_password }}@{{ rabbitmq_host }}/{{ rabbitmq_vhost | urlencode | replace('/', '%2F') }}"
DATABASE_URL: "ecto://{{ web_postgres_user }}:{{ web_postgres_password }}@{{ web_postgres_host }}/{{ web_postgres_db }}"
EVENTSTORE_URL: "ecto://{{ web_postgres_user }}:{{ web_postgres_password }}@{{ web_postgres_host }}/{{ web_postgres_event_store }}"
ENABLE_ALERTING: "{{ enable_alerting }}"
# SMTP_SERVER: "{{ .Values.alerting.smtpServer }}"
# SMTP_PORT: "{{ .Values.alerting.smtpPort }}"
# SMTP_USER: "{{ .Values.alerting.smtpUser }}"
# SMTP_PASSWORD: "{{ .Values.alerting.smtpPassword }}"
# ALERT_SENDER: "{{ .Values.alerting.sender }}"
# ALERT_RECIPIENT: "{{ .Values.alerting.recipient }}"
PROMETHEUS_URL: "{{ prometheus_url }}"
SECRET_KEY_BASE: "{{ secret_key_base }}"
ACCESS_TOKEN_ENC_SECRET: "{{ access_token_secret }}"
REFRESH_TOKEN_ENC_SECRET: "{{ refresh_token_secret }}"
ADMIN_USER: "{{ web_admin_username }}"
ADMIN_PASSWORD: "{{ web_admin_password }}"
ENABLE_API_KEY: "{{ enable_api_key }}"
name: "{{ web_container_name }}"
state: started
recreate: "{{ force_recreate_web_container == 'true' }}"
restart_policy: unless-stopped
image: "{{ web_container_image }}"
pull: true
networks:
- name: "{{ docker_network_name }}"
entrypoint:
[
"/bin/sh",
"-c",
'/app/bin/trento eval "Trento.Release.init()" && /app/bin/trento start',
]
etc_hosts:
host.docker.internal: "host-gateway"
ports:
- "{{ web_container_port }}:4000"
env:
AMQP_URL: "{{ amqp_protocol }}://{{ rabbitmq_username }}:{{ rabbitmq_password }}@{{ rabbitmq_host }}/{{ rabbitmq_vhost | urlencode | replace('/', '%2F') }}"
DATABASE_URL: "ecto://{{ web_postgres_user }}:{{ web_postgres_password }}@{{ web_postgres_host }}/{{ web_postgres_db }}"
EVENTSTORE_URL: "ecto://{{ web_postgres_user }}:{{ web_postgres_password }}@{{ web_postgres_host }}/{{ web_postgres_event_store }}"
ENABLE_ALERTING: "{{ enable_alerting }}"
# SMTP_SERVER: "{{ .Values.alerting.smtpServer }}"
# SMTP_PORT: "{{ .Values.alerting.smtpPort }}"
# SMTP_USER: "{{ .Values.alerting.smtpUser }}"
# SMTP_PASSWORD: "{{ .Values.alerting.smtpPassword }}"
# ALERT_SENDER: "{{ .Values.alerting.sender }}"
# ALERT_RECIPIENT: "{{ .Values.alerting.recipient }}"
PROMETHEUS_URL: "{{ prometheus_url }}"
SECRET_KEY_BASE: "{{ secret_key_base }}"
ACCESS_TOKEN_ENC_SECRET: "{{ access_token_secret }}"
REFRESH_TOKEN_ENC_SECRET: "{{ refresh_token_secret }}"
ADMIN_USER: "{{ web_admin_username }}"
ADMIN_PASSWORD: "{{ web_admin_password }}"
ENABLE_API_KEY: "{{ enable_api_key }}"
4 changes: 2 additions & 2 deletions roles/postgres/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
---
- name: Restart postgres
ansible.builtin.service:
name: postgresql
state: restarted
name: postgresql
state: restarted
Loading

0 comments on commit 09078e7

Please sign in to comment.