diff --git a/roles/mongodb/defaults/main.yml b/roles/mongodb/defaults/main.yml index a96fe6f99..1c54103e7 100644 --- a/roles/mongodb/defaults/main.yml +++ b/roles/mongodb/defaults/main.yml @@ -15,7 +15,7 @@ # mongodb_enabled: False -# mongodb_port: 27018 +# mongodb_port: 27017 # All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! diff --git a/roles/mongodb/tasks/install.yml b/roles/mongodb/tasks/install.yml index 71e111b2e..3f1eb6578 100644 --- a/roles/mongodb/tasks/install.yml +++ b/roles/mongodb/tasks/install.yml @@ -114,12 +114,12 @@ - mongodb-org-server state: present - - name: Change {{ mongodb_conf }} port to {{ mongodb_port }} -- takes effect on next (re)start of the service -- via enable-or-disable.yml or via sugarizer.service auto-starting MongoDB on demand + - name: Establish {{ mongodb_conf }} port {{ mongodb_port }} (mongodb_conf) -- takes effect on next (re)start of the service -- via enable-or-disable.yml or via sugarizer.service auto-starting MongoDB on demand lineinfile: path: "{{ mongodb_conf }}" - regexp: "port: 27017" - backrefs: yes - line: " port: {{ mongodb_port }}" # 27018 + regexp: '^\s*port:' # \s = any whitespace char. stackoverflow.com/a/38491899 + #backrefs: yes + line: " port: {{ mongodb_port }}" # 27017 # end block when: (ansible_architecture == "aarch64") or (ansible_architecture == "x86_64") diff --git a/roles/mongodb/templates/mongod.conf.j2 b/roles/mongodb/templates/mongod.conf.j2 index 9d9c9c9c1..8d450c508 100644 --- a/roles/mongodb/templates/mongod.conf.j2 +++ b/roles/mongodb/templates/mongod.conf.j2 @@ -5,7 +5,12 @@ # Comma separated list of ip addresses to listen on (all local ips by default) bind_ip = 127.0.0.1 -# Specify port number (27017 by default...but typically 27018 for IIAB) +# mongodb_port is set to 27017 in /opt/iiab/iiab/vars/default_vars.yml +# If you must change this, it's best to edit /etc/iiab/local_vars.yml prior to +# installing IIAB. Please also see upstream recommendations: +# https://github.com/llaske/sugarizer-server/blob/master/env/sugarizer.ini line ~22 under [database] +# https://docs.mongodb.com/manual/reference/default-mongodb-port/ +# https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt port = {{ mongodb_port }} # Fork server process (false by default) diff --git a/roles/sugarizer/tasks/install.yml b/roles/sugarizer/tasks/install.yml index f478457ff..ac490d70e 100644 --- a/roles/sugarizer/tasks/install.yml +++ b/roles/sugarizer/tasks/install.yml @@ -176,7 +176,7 @@ - name: Set Sugarizer port to {{ sugarizer_port }} in /opt/iiab/sugarizer-server/env/sugarizer.ini lineinfile: path: "{{ iiab_base }}/sugarizer-server/env/sugarizer.ini" - regexp: "^port = 8080$" + regexp: '^port = 8080$' line: "port = {{ sugarizer_port }}" # 2019-02-02 No Longer Required thanks to @llaske's upstream fix: @@ -193,15 +193,19 @@ #- name: Set MongoDB "server" from localhost to 127.0.0.1 in /opt/iiab/sugarizer-server/env/sugarizer.ini # lineinfile: # path: "{{ iiab_base }}/sugarizer-server/env/sugarizer.ini" -# regexp: "^server = localhost$" +# regexp: '^server = localhost$' # line: "server = 127.0.0.1" -# mongodb_port is set to 27018 in /opt/iiab/iiab/vars/default_vars.yml -# If you need to change this, edit /etc/iiab/local_vars.yml prior to installing +# mongodb_port is set to 27017 in /opt/iiab/iiab/vars/default_vars.yml +# If you must change this, it's best to edit /etc/iiab/local_vars.yml prior to +# installing IIAB. Please also see upstream recommendations: +# https://github.com/llaske/sugarizer-server/blob/master/env/sugarizer.ini line ~22 under [database] +# https://docs.mongodb.com/manual/reference/default-mongodb-port/ +# https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt - name: Set MongoDB port to {{ mongodb_port }} in /opt/iiab/sugarizer-server/env/sugarizer.ini lineinfile: path: "{{ iiab_base }}/sugarizer-server/env/sugarizer.ini" - regexp: "^port = 27017$" + regexp: '^port = 27017$' # Careful as file also contains 2 other ports! line: "port = {{ mongodb_port }}" # 2-LINE FIX FOR sugarizer.js BY @georgejhunt FOR http://box/sugarizer @@ -211,7 +215,7 @@ - name: For http://box/sugarizer -- add pathPrefix lines in /opt/iiab/sugarizer-server/sugarizer.js lineinfile: path: "{{ iiab_base }}/sugarizer-server/sugarizer.js" - regexp: "AUTO-INSERTED BY IIAB" # avoids inserting it twice! + regexp: 'AUTO-INSERTED BY IIAB' # avoids inserting it twice! insertbefore: "// Start listening$" line: | # SEE https://yaml-multiline.info (use |+ to 'keep' newlines at end...though |8 and |+4 "indentation indicators" don't work with Ansible) // AUTO-INSERTED BY IIAB FOR http://box/sugarizer diff --git a/vars/default_vars.yml b/vars/default_vars.yml index c71774088..916dbb88a 100644 --- a/vars/default_vars.yml +++ b/vars/default_vars.yml @@ -485,7 +485,7 @@ mongodb_install: False # misleading as Sugarizer starts mongodb's systemd service on its own, due to # 'Requires=mongodb.service' within /etc/systemd/system/sugarizer.service mongodb_enabled: False -mongodb_port: 27018 +mongodb_port: 27017 # roles/sugarizer/meta/main.yml auto-invokes 2 above prereqs: mongodb & nodejs # Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879