Skip to content

Commit 04bf933

Browse files
authored
Fix/remove container from inventory (#486)
* get mongo servers from variables not inventory entries
1 parent 75d5e19 commit 04bf933

7 files changed

Lines changed: 17 additions & 6 deletions

File tree

roles/manage/templates/application.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ spring:
7979
port: 25
8080
data:
8181
mongodb:
82-
uri: mongodb://{{ manage.mongo_user }}:{{ manage.mongo_password }}@{% for host in groups['mongo_servers'] %}{{ hostvars[host]['inventory_hostname'] }}:{{ manage.mongo_port }}{% if not loop.last %},{% endif %}{% endfor %}/{{ manage.mongo_database }}?ssl={{ mongodb_ssl | default('true') }}
82+
uri: mongodb://{{ manage.mongo_user }}:{{ manage.mongo_password }}@{% for mongo_server in manage.mongo_servers %}{{ mongo_server }}:{{ manage.mongo_port }}{% if not loop.last %},{% endif %}{% endfor %}/{{ manage.mongo_database }}?ssl={{ mongodb_ssl | default('true') }}
8383
main:
8484
banner-mode: "off"
8585

roles/manage_provision_entities/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
body:
3535
entityid: "{{ manage_provision_client_id }}"
3636
run_once: true
37+
check_mode: false # This can safely run in check mode because it is not changing anything
3738
register: manage_test_entity
3839
until: manage_test_entity is succeeded
3940
retries: 15

roles/mongo/defaults/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# The global variable file mongodb installation
22

3+
# In the current mongo role only one cluster per environments
4+
# is possible, that works for now.
5+
mongo_servers: [] # Set this in group_vars
6+
# - mongo1.example.com
7+
# - mongo2.example.com
8+
39
# The port for mongo server
410
mongod_port: 27017
511

612
# The password for admin user
7-
mongo_admin_pass: "{{ mongo_admin_password }}"
13+
mongo_admin_pass: "{{ mongo_admin_password }}" # Set this in secrets
814

915
# The name of the replication set
10-
replica_set_name: "{{ instance_name }}"
16+
replica_set_name: "{{ instance_name }}" # Set this in group_vars
1117

1218
# Add a database
1319
mongo:

roles/mongo/tasks/postinstall.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
owner: root
3535
when: mongo_replication_role != 'arbiter'
3636

37+
# TODO: this template gets mongo_servers from
38+
# the inventory, maybe change that to group vars
39+
# this is not on an per app basis. These are mongoservers
40+
# in the same cluster.
3741
- name: Create mongosh config file
3842
ansible.builtin.template:
3943
src: mongoshrc.js.j2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
db = connect("mongodb://admin:{{ mongo_admin_password }}@{% for host in groups['mongo_servers'] %}{{ hostvars[host]['inventory_hostname'] }}:{{ mongod_port }}{% if not loop.last %},{% endif %}{% endfor %}?ssl=true&tlsCAFile=/etc/pki/mongo/mongoca.pem")
1+
db = connect("mongodb://admin:{{ mongo_admin_password }}@{% for mongo_server in mongo_servers %}{{ mongo_server }}:{{ mongod_port }}{% if not loop.last %},{% endif %}{% endfor %}?ssl=true&tlsCAFile=/etc/pki/mongo/mongoca.pem")
22

roles/myconext/templates/application.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ verify:
234234
spring:
235235
data:
236236
mongodb:
237-
uri: mongodb://{{ myconext.mongo_user }}:{{ myconext.mongo_password }}@{% for host in groups['mongo_servers'] %}{{ hostvars[host]['inventory_hostname'] }}:{{ myconext.mongo_port }}{% if not loop.last %},{% endif %}{% endfor %}/{{ myconext.mongo_database }}?ssl={{ mongodb_ssl | default('true') }}
237+
uri: mongodb://{{ myconext.mongo_user }}:{{ myconext.mongo_password }}@{% for mongo_server in myconext.mongo_servers %}{{ mongo_server }}:{{ myconext.mongo_port }}{% if not loop.last %},{% endif %}{% endfor %}/{{ myconext.mongo_database }}?ssl={{ mongodb_ssl | default('true') }}
238238

239239
mail:
240240
host: {{ smtp_server }}

roles/oidcng/templates/application.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ idp:
7676
spring:
7777
data:
7878
mongodb:
79-
uri: "mongodb://{{ oidcng.mongo_user }}:{{ oidcng.mongo_password }}@{% for host in groups['mongo_servers'] %}{{ hostvars[host]['inventory_hostname'] }}:{{ oidcng.mongo_port }}{% if not loop.last %},{% endif %}{%endfor %}/{{ oidcng.mongo_database }}?ssl={{ mongodb_ssl | default('true') }}"
79+
uri: "mongodb://{{ oidcng.mongo_user }}:{{ oidcng.mongo_password }}@{% for mongo_server in oidcng.mongo_servers %}{{ mongo_server }}:{{ oidcng.mongo_port }}{% if not loop.last %},{% endif %}{%endfor %}/{{ oidcng.mongo_database }}?ssl={{ mongodb_ssl | default('true') }}"
8080

8181
thymeleaf:
8282
cache: true

0 commit comments

Comments
 (0)