mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	
						commit
						5e87b14598
					
				
					 18 changed files with 139 additions and 167 deletions
				
			
		| 
						 | 
				
			
			@ -35,9 +35,10 @@
 | 
			
		|||
    path: /etc/iiab/diag
 | 
			
		||||
    mode: '0777'
 | 
			
		||||
 | 
			
		||||
- name: Re-read local_facts.facts from /etc/ansible/facts.d
 | 
			
		||||
  setup:
 | 
			
		||||
    filter: ansible_local
 | 
			
		||||
# 2020-10-29: Appears no longer nec (see 3 above ansible_local.local_facts.*)
 | 
			
		||||
#- name: Re-read local_facts.facts from /etc/ansible/facts.d
 | 
			
		||||
#  setup:
 | 
			
		||||
#    filter: ansible_local
 | 
			
		||||
 | 
			
		||||
- name: Pre-check that IIAB's "XYZ_install" + "XYZ_enabled" vars (1) are defined, (2) are boolean-not-string variables, and (3) contain plausible values.  Also checks that "XYZ_install" is True when "XYZ_installed" is defined.
 | 
			
		||||
  include_tasks: validate_vars.yml
 | 
			
		||||
| 
						 | 
				
			
			@ -167,4 +168,4 @@
 | 
			
		|||
  when: is_VM is defined
 | 
			
		||||
 | 
			
		||||
- name: STAGE 0 HAS COMPLETED ======================================
 | 
			
		||||
  meta: noop
 | 
			
		||||
  command: echo    # "name: XYZ" fails to appear with "meta: noop"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,6 @@
 | 
			
		|||
- include_tasks: net_mods.yml
 | 
			
		||||
  when: not is_debuntu and not is_F18
 | 
			
		||||
 | 
			
		||||
- include_tasks: udev.yml
 | 
			
		||||
- include_tasks: iiab-startup.yml
 | 
			
		||||
 | 
			
		||||
- name: Recording STAGE 2 HAS COMPLETED ==========================
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,41 +0,0 @@
 | 
			
		|||
- name: Does systemd-udevd.service exist
 | 
			
		||||
  stat:
 | 
			
		||||
    path: "{{ systemd_location }}/systemd-udevd.service"
 | 
			
		||||
  register: udev_unit
 | 
			
		||||
 | 
			
		||||
- name: Copy udevd service to /etc/systemd/system to modify
 | 
			
		||||
  copy:
 | 
			
		||||
    src: "{{ systemd_location }}/systemd-udevd.service"
 | 
			
		||||
    dest: /etc/systemd/system/systemd-udevd.service
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: 0644
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
 | 
			
		||||
- name: Change MountFlags from slave to shared
 | 
			
		||||
  lineinfile:
 | 
			
		||||
    backup: no
 | 
			
		||||
    dest: /etc/systemd/system/systemd-udevd.service
 | 
			
		||||
    regexp: '^MountFlags'
 | 
			
		||||
    line: 'MountFlags=shared'
 | 
			
		||||
    state: present
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
 | 
			
		||||
- name: Add udev-reload.service after all filesystems are available as read-write during boot
 | 
			
		||||
  template:
 | 
			
		||||
    src: udev-reload.service
 | 
			
		||||
    dest: /etc/systemd/system/
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
 | 
			
		||||
- name: Ask systemd to reread unit files (daemon-reload) and restart so systemd recognizes the changes
 | 
			
		||||
  systemd:
 | 
			
		||||
    daemon_reload: yes
 | 
			
		||||
    name: systemd-udevd
 | 
			
		||||
    state: restarted
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
 | 
			
		||||
- name: Enable the udev-reload service during boot
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: udev-reload
 | 
			
		||||
    enabled: yes
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
| 
						 | 
				
			
			@ -1,9 +0,0 @@
 | 
			
		|||
[Unit]
 | 
			
		||||
Description=Make sure udev is operating on RW disk
 | 
			
		||||
After=network-online.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
ExecStart=/bin/systemctl restart systemd-udevd.service
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
							
								
								
									
										13
									
								
								roles/mongodb/tasks/enable-or-disable.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								roles/mongodb/tasks/enable-or-disable.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
- name: Enable & (Re)Start 'mongodb.service' if mongodb_enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: mongodb
 | 
			
		||||
    enabled: yes
 | 
			
		||||
    state: restarted
 | 
			
		||||
  when: mongodb_enabled
 | 
			
		||||
 | 
			
		||||
- name: Disable & Stop 'mongodb.service' if not mongodb_enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: mongodb
 | 
			
		||||
    enabled: no
 | 
			
		||||
    state: stopped
 | 
			
		||||
  when: not mongodb_enabled
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
  - name: Download & unzip 20MB http://download.iiab.io/packages/mongodb_stretch_3_0_14_core.zip to /tmp/mongodb-3.0.1x (aarch32)
 | 
			
		||||
    unarchive:
 | 
			
		||||
      remote_src: yes
 | 
			
		||||
      src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_core.zip"
 | 
			
		||||
      src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_core.zip"    # http://download.iiab.io/packages
 | 
			
		||||
      dest: /tmp/mongodb-3.0.1x
 | 
			
		||||
 | 
			
		||||
  - name: Install (move) its 3 CORE binaries from /tmp/mongodb-3.0.1x/core to /usr/bin (aarch32)
 | 
			
		||||
| 
						 | 
				
			
			@ -47,24 +47,22 @@
 | 
			
		|||
      home: /var/lib/mongodb
 | 
			
		||||
      shell: /usr/sbin/nologin
 | 
			
		||||
 | 
			
		||||
  - name: Install /etc/mongod.conf from template (aarch32)
 | 
			
		||||
  - name: Install {{ mongodb_conf }} from template (aarch32)
 | 
			
		||||
    template:
 | 
			
		||||
      src: "{{ item.src }}"
 | 
			
		||||
      dest: "{{ item.dest }}"
 | 
			
		||||
      owner: root
 | 
			
		||||
      group: root
 | 
			
		||||
      mode: "{{ item.mode }}"
 | 
			
		||||
    with_items:
 | 
			
		||||
      - { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}", mode: '0644' }    # i.e. /etc/mongod.conf
 | 
			
		||||
      src: mongod.conf.j2
 | 
			
		||||
      dest: "{{ mongodb_conf }}"    # /etc/mongod.conf
 | 
			
		||||
      #owner: root
 | 
			
		||||
      #group: root
 | 
			
		||||
      #mode: 0644
 | 
			
		||||
 | 
			
		||||
  # end block
 | 
			
		||||
  when: not (ansible_architecture == "x86_64" or ansible_architecture == "aarch64")
 | 
			
		||||
 | 
			
		||||
# 32 bit OS's get caught above should handle aarch32 including 32-bit ubuntu
 | 
			
		||||
# from https://ubuntu.com/download/raspberry-pi. 20.4-32bit might fail untested
 | 
			
		||||
# 32bit intel might puke as this was orginally deployed for raspbian. Haven't
 | 
			
		||||
# see bootable 32bit intel installers for a while now.
 | 
			
		||||
# 64 bit OS's proceed below.
 | 
			
		||||
# 32-bit OS's are handled above: this should handle aarch32 including 32-bit Ubuntu
 | 
			
		||||
# from https://ubuntu.com/download/raspberry-pi but Ubuntu 20.04 32-bit might fail
 | 
			
		||||
# untested, and 32-bit Intel might puke as this was orginally deployed for Raspbian.
 | 
			
		||||
# (Haven't seen bootable 32-bit Intel installers for a while now.)
 | 
			
		||||
# 64-bit OS's proceed below.
 | 
			
		||||
 | 
			
		||||
- block:
 | 
			
		||||
  - name: Add mongodb.org signing key (only 64-bit support available)
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +72,11 @@
 | 
			
		|||
 | 
			
		||||
  - name: Use mongodb-org's Debian repo for Debian (only amd64 support available)
 | 
			
		||||
    apt_repository:
 | 
			
		||||
      repo: deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.4 main
 | 
			
		||||
      # 2020-10-28: http://repo.mongodb.org/apt/debian/dists/ supports only
 | 
			
		||||
      # {buster 10, stretch 9, jessie 8, wheezy 7}
 | 
			
		||||
      # so Debian 11 "Bullseye" (testing branch) can revert to buster for now:
 | 
			
		||||
      repo: deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main
 | 
			
		||||
      #repo: deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.4 main
 | 
			
		||||
      state: present
 | 
			
		||||
      filename: mongodb-org
 | 
			
		||||
    when: is_debian and (ansible_architecture == "x86_64")
 | 
			
		||||
| 
						 | 
				
			
			@ -112,12 +114,12 @@
 | 
			
		|||
        - mongodb-org-server
 | 
			
		||||
      state: present
 | 
			
		||||
 | 
			
		||||
  - name: Change the mongodb port to 27018
 | 
			
		||||
  - 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
 | 
			
		||||
    lineinfile:
 | 
			
		||||
      path: /etc/mongod.conf
 | 
			
		||||
      regexp: 'port: 27017'
 | 
			
		||||
      path: "{{ mongodb_conf }}"
 | 
			
		||||
      regexp: "port: 27017"
 | 
			
		||||
      backrefs: yes
 | 
			
		||||
      line: '  port: 27018'
 | 
			
		||||
      line: "  port: {{ mongodb_port }}"    # 27018
 | 
			
		||||
 | 
			
		||||
  # end block
 | 
			
		||||
  when: (ansible_architecture == "aarch64") or (ansible_architecture == "x86_64")
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +137,7 @@
 | 
			
		|||
    #- { path: '/var/run/mongodb' }
 | 
			
		||||
    - /var/lib/mongodb
 | 
			
		||||
    - /var/log/mongodb
 | 
			
		||||
    - "{{ mongodb_db_path }}"    # i.e. /library/dbdata/mongodb/
 | 
			
		||||
    - "{{ mongodb_db_path }}"    # /library/dbdata/mongodb
 | 
			
		||||
 | 
			
		||||
- name: Install mongodb.service, /usr/bin/iiab-mongodb-repair-if-no-lock from templates
 | 
			
		||||
  template:
 | 
			
		||||
| 
						 | 
				
			
			@ -148,14 +150,9 @@
 | 
			
		|||
    - { src: 'mongodb.service.j2', dest: '/etc/systemd/system/mongodb.service', mode: '0644' }
 | 
			
		||||
    - { src: 'iiab-mongodb-repair-if-no-lock.j2', dest: '/usr/bin/iiab-mongodb-repair-if-no-lock', mode: '0755' }
 | 
			
		||||
 | 
			
		||||
# daemon_reload is used to force systemd to recognize a newly installed .service file
 | 
			
		||||
# restarted here to ensure the port has been changed
 | 
			
		||||
- name: Disable 'mongodb' systemd service - started on demand by sugarizer
 | 
			
		||||
- name: systemctl daemon_reload, so systemd (re)reads mongodb.service
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: mongodb
 | 
			
		||||
    daemon_reload: yes
 | 
			
		||||
    enabled: no
 | 
			
		||||
    state: restarted
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# 3. RECORD MongoDB AS INSTALLED
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,10 @@
 | 
			
		|||
    var: mongodb_installed
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- debug:
 | 
			
		||||
    var: rpi_model    # 0-init sets it from ansible_local.local_facts.rpi_model
 | 
			
		||||
- debug:
 | 
			
		||||
    var: ansible_local.local_facts.os_ver   # Like OS_VER in /etc/iiab/iiab.env
 | 
			
		||||
- debug:
 | 
			
		||||
    var: is_debian
 | 
			
		||||
- debug:
 | 
			
		||||
| 
						 | 
				
			
			@ -39,19 +43,16 @@
 | 
			
		|||
  ignore_errors: yes
 | 
			
		||||
 | 
			
		||||
# ELSE...
 | 
			
		||||
 | 
			
		||||
- name: Install MongoDB if 'mongodb_installed' not defined, e.g. in {{ iiab_state_file }}    # /etc/iiab/iiab_state.yml
 | 
			
		||||
  include_tasks: install.yml
 | 
			
		||||
  when: mongodb_installed is undefined and not (ansible_architecture == "aarch64" and is_debian_10 and not is_raspbian)
 | 
			
		||||
 | 
			
		||||
- name: Disable & Stop 'mongodb' service, if not mongodb_enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: mongodb
 | 
			
		||||
    enabled: no
 | 
			
		||||
    state: stopped
 | 
			
		||||
  when: not mongodb_enabled and mongodb_installed is defined
 | 
			
		||||
 | 
			
		||||
#'mongodb' systemd service - started on demand by sugarizer
 | 
			
		||||
# Just recording that mongodb should be running
 | 
			
		||||
- name: Enable or Disable MongoDB, if mongodb_installed is defined (sugarizer.service auto-starts MongoDB as nec, so doesn't need this or care what happens here!)
 | 
			
		||||
  include_tasks: enable-or-disable.yml
 | 
			
		||||
  when: mongodb_installed is defined
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Add 'mongodb' variable values to {{ iiab_ini_file }}
 | 
			
		||||
  ini_file:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +0,0 @@
 | 
			
		|||
- name: Enable http://box/sugarizer & http://box/sugar via Apache
 | 
			
		||||
  command: a2ensite sugarizer.conf
 | 
			
		||||
  when: sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
- name: Disable http://box/sugarizer & http://box/sugar via Apache
 | 
			
		||||
  command: a2dissite sugarizer.conf
 | 
			
		||||
  when: not sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
- name: (Re)Start '{{ apache_service }}' systemd service
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: "{{ apache_service }}"    # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
 | 
			
		||||
    state: restarted
 | 
			
		||||
							
								
								
									
										32
									
								
								roles/sugarizer/tasks/enable-or-disable.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								roles/sugarizer/tasks/enable-or-disable.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
- name: Enable & (Re)Start 'sugarizer.service' (WHICH AUTO-STARTS BUT DOES NOT ENABLE OR DISABLE 'mongodb.service', LIKEWISE WE DON'T TOUCH ANSIBLE VAR mongodb_enabled) if sugarizer_enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: sugarizer
 | 
			
		||||
    enabled: yes
 | 
			
		||||
    state: restarted
 | 
			
		||||
  when: sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
- name: Disable & Stop 'sugarizer.service' (BUT LEAVE 'mongodb.service' COMPLETELY UNCHANGED, LIKEWISE WE DON'T TOUCH ANSIBLE VAR mongodb_enabled) if not sugarizer_enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: sugarizer
 | 
			
		||||
    enabled: no
 | 
			
		||||
    state: stopped
 | 
			
		||||
  when: not sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Enable http://box/sugarizer if sugarizer_enabled, by installing {{ nginx_conf_dir }}/sugarizer-nginx.conf from template
 | 
			
		||||
  template:
 | 
			
		||||
    src: sugarizer-nginx.conf
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/sugarizer-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
  when: sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
- name: Disable http://box/sugarizer if not sugarizer_enabled, by removing {{ nginx_conf_dir }}/sugarizer-nginx.conf
 | 
			
		||||
  file:
 | 
			
		||||
    path: "{{ nginx_conf_dir }}/sugarizer-nginx.conf"
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Restart 'nginx' systemd service
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: nginx
 | 
			
		||||
    state: restarted
 | 
			
		||||
| 
						 | 
				
			
			@ -20,10 +20,11 @@
 | 
			
		|||
    msg: "Sugarizer install cannot proceed, as Node.js is not installed."
 | 
			
		||||
  when: nodejs_installed is undefined
 | 
			
		||||
 | 
			
		||||
- name: FAIL (STOP THE INSTALL) IF 'nodejs_version != "12.x"'
 | 
			
		||||
  fail:
 | 
			
		||||
    msg: "Sugarizer install cannot proceed, as it currently requires Node.js 12.x, whereas nodejs_version is set to {{ nodejs_version }}.  Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc."
 | 
			
		||||
  when: nodejs_version != "12.x"
 | 
			
		||||
# 2020-10-29: No longer nec as Sugarizer works on most all versions of Node.js
 | 
			
		||||
#- name: FAIL (STOP THE INSTALL) IF 'nodejs_version != "12.x"'
 | 
			
		||||
#  fail:
 | 
			
		||||
#    msg: "Sugarizer install cannot proceed, as it currently requires Node.js 12.x, whereas nodejs_version is set to {{ nodejs_version }}.  Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc."
 | 
			
		||||
#  when: nodejs_version != "12.x"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# 2. DOWNLOAD+LINK /opt/iiab/sugarizer
 | 
			
		||||
| 
						 | 
				
			
			@ -153,11 +154,16 @@
 | 
			
		|||
    src: sugarizer.service
 | 
			
		||||
    dest: /etc/systemd/system
 | 
			
		||||
 | 
			
		||||
- name: "Install from template: /etc/{{ apache_conf_dir }}/sugarizer.conf"
 | 
			
		||||
  template:
 | 
			
		||||
    src: sugarizer.conf.j2
 | 
			
		||||
    dest: "/etc/{{ apache_conf_dir }}/sugarizer.conf"    # apache2/sites-available
 | 
			
		||||
  when: apache_installed is defined
 | 
			
		||||
- name: systemctl daemon_reload, so systemd (re)reads sugarizer.service
 | 
			
		||||
  systemd:
 | 
			
		||||
    daemon_reload: yes
 | 
			
		||||
 | 
			
		||||
# 2020-10-30: PR #2604 tries a cleaner layout, with NGINX only
 | 
			
		||||
#- name: "Install from template: /etc/{{ apache_conf_dir }}/sugarizer.conf"
 | 
			
		||||
#  template:
 | 
			
		||||
#    src: sugarizer.conf.j2
 | 
			
		||||
#    dest: "/etc/{{ apache_conf_dir }}/sugarizer.conf"    # apache2/sites-available
 | 
			
		||||
#  when: apache_installed is defined
 | 
			
		||||
 | 
			
		||||
# 3 [WAS 4] STANZAS ADDED BELOW JAN/FEB 2019, HOPING THIS MIGHT "JUST WORK"
 | 
			
		||||
# WITH FUTURE UPGRADES BEYOND SUGARIZER 1.1?!
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,25 +19,22 @@
 | 
			
		|||
    quiet: yes
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# 3 stanzas moved up from install.yml, so Debian finishes "BIG" IIAB install:
 | 
			
		||||
# (WITH LOUD RED WARNINGS!)
 | 
			
		||||
# 3 stanzas moved up from install.yml, so Debian-or-any-OS-where-MongoDB-fails
 | 
			
		||||
# still finish their "BIG-sized" IIAB install: (WITH LOUD RED WARNINGS!)
 | 
			
		||||
 | 
			
		||||
# If we got here sugarizer_install is True
 | 
			
		||||
- name: "Set 'mongodb_install: True'"
 | 
			
		||||
  set_fact:
 | 
			
		||||
    mongodb_install: True
 | 
			
		||||
 | 
			
		||||
# MongoDB auto-started by sugarizer.service - let's set 'mongodb_enabled: True'
 | 
			
		||||
# regardless - anticipating that MongoDB (should!) run on demand:
 | 
			
		||||
- name: "Set 'mongodb_enabled: True' when sugarizer_enabled"
 | 
			
		||||
  set_fact:
 | 
			
		||||
    mongodb_enabled: True
 | 
			
		||||
  when: sugarizer_enabled
 | 
			
		||||
- name: 'CAUTION: IF ''mongodb.service'' IS STOPPED FOR ANY REASON, IT WILL IMMEDIATELY CAUSE SUGARIZER TO FAIL ("502 Bad Gateway") !'
 | 
			
		||||
  debug:
 | 
			
		||||
    msg: "/etc/systemd/system/sugarizer.service Line 4 'Requires=mongodb.service' tries to auto-start MongoDB every time Sugarizer starts.  IIAB (roles/mongodb/tasks/enable-or-disable.yml) tries its best to keep Ansible var 'mongodb_enabled' in sync with its systemd equivalent, i.e. the output of 'systemctl is-enabled mongodb' (as of 2020-10-29 both are typically disabled, unless other apps/services/operators choose to use MongoDB)."
 | 
			
		||||
 | 
			
		||||
- name: MONGODB - run 'mongodb' role (attempt to install MongoDB)
 | 
			
		||||
  include_role:
 | 
			
		||||
    name: mongodb
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: EXIT 'sugarizer' ROLE & CONTINUE, IF 'mongodb_installed is undefined'
 | 
			
		||||
  fail:    # FORCE IT RED THIS ONCE!
 | 
			
		||||
    msg: MongoDB INSTALLATION FAILED, perhaps because your OS is Debian 10 on aarch64?  Nevertheless IIAB will continue (consider this a warning!)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,38 +2,8 @@
 | 
			
		|||
  include_tasks: install.yml
 | 
			
		||||
  when: sugarizer_installed is undefined
 | 
			
		||||
 | 
			
		||||
- block:    # 2 STANZAS BELOW, CONDITIONED ON 'when: sugarizer_enabled'
 | 
			
		||||
 | 
			
		||||
  # LIKELY UNNEC: THIS SAME CODE IS IN main.yml (LINES 32-35, ALREADY RUN)
 | 
			
		||||
  # sugarizer.service line 'Requires=mongodb.service' auto-starts MongoDB (but record that in var too)
 | 
			
		||||
  - name: "Set 'mongodb_enabled: True' if sugarizer_enabled"
 | 
			
		||||
    set_fact:
 | 
			
		||||
      mongodb_enabled: True
 | 
			
		||||
 | 
			
		||||
  - name: Enable & Restart 'sugarizer' systemd service, if sugarizer_enabled
 | 
			
		||||
    systemd:
 | 
			
		||||
      name: sugarizer
 | 
			
		||||
      daemon_reload: yes    # In case mongodb.service changed, etc
 | 
			
		||||
      enabled: yes
 | 
			
		||||
      state: restarted
 | 
			
		||||
 | 
			
		||||
  when: sugarizer_enabled    # CONDITION FOR 2-STANZA block: ABOVE
 | 
			
		||||
 | 
			
		||||
  # Stops 'sugarizer' but not 'mongodb'
 | 
			
		||||
- name: Disable & Stop 'sugarizer' systemd service, if not sugarizer_enabled
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: sugarizer
 | 
			
		||||
    enabled: no
 | 
			
		||||
    state: stopped
 | 
			
		||||
  when: not sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
- name: Enable/Disable/Restart Apache if primary
 | 
			
		||||
  include_tasks: apache.yml
 | 
			
		||||
  when: not nginx_enabled
 | 
			
		||||
 | 
			
		||||
- name: Enable/Disable/Restart NGINX if primary
 | 
			
		||||
  include_tasks: nginx.yml
 | 
			
		||||
  when: nginx_enabled
 | 
			
		||||
- include_tasks: enable-or-disable.yml
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Add 'sugarizer' variable values to {{ iiab_ini_file }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,16 +0,0 @@
 | 
			
		|||
- name: Enable http://box/sugarizer via NGINX, by installing {{ nginx_conf_dir }}/sugarizer-nginx.conf from template
 | 
			
		||||
  template:
 | 
			
		||||
    src: sugarizer-nginx.conf
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/sugarizer-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
  when: sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
- name: Disable http://box/sugarizer via NGINX, by removing {{ nginx_conf_dir }}/sugarizer-nginx.conf
 | 
			
		||||
  file:
 | 
			
		||||
    path: "{{ nginx_conf_dir }}/sugarizer-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not sugarizer_enabled
 | 
			
		||||
 | 
			
		||||
- name: Restart 'nginx' systemd service
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: nginx
 | 
			
		||||
    state: restarted
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +1,33 @@
 | 
			
		|||
- name: Does systemd-udevd.service exist
 | 
			
		||||
  stat:
 | 
			
		||||
    path: "{{ systemd_location }}/systemd-udevd.service"
 | 
			
		||||
  register: udev_unit
 | 
			
		||||
 | 
			
		||||
- name: Copy udevd service to /etc/systemd/system to modify
 | 
			
		||||
  copy:
 | 
			
		||||
    src: "{{ systemd_location }}/systemd-udevd.service"
 | 
			
		||||
    dest: /etc/systemd/system/systemd-udevd.service
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: 0644
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
 | 
			
		||||
- name: Change MountFlags from slave to shared
 | 
			
		||||
  lineinfile:
 | 
			
		||||
    backup: no
 | 
			
		||||
    dest: /etc/systemd/system/systemd-udevd.service
 | 
			
		||||
    regexp: '^MountFlags'
 | 
			
		||||
    line: 'MountFlags=shared'
 | 
			
		||||
    state: present
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
 | 
			
		||||
- name: Ask systemd to reread unit files (daemon-reload) and restart so systemd recognizes the changes
 | 
			
		||||
  systemd:
 | 
			
		||||
    daemon_reload: yes
 | 
			
		||||
    name: systemd-udevd
 | 
			
		||||
    state: restarted
 | 
			
		||||
  when: udev_unit.stat.exists is defined and udev_unit.stat.exists
 | 
			
		||||
 | 
			
		||||
#http://raspbian.raspberrypi.org/raspbian/pool/main/u/usbmount/usbmount_0.0.22_all.deb
 | 
			
		||||
- name: Install {{ iiab_download_url }}/usbmount_0.0.22_all.deb, missing from Debian
 | 
			
		||||
  apt:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,6 +113,7 @@ echo >> $outfile
 | 
			
		|||
echo "iiab commit:               $HASH1" >> $outfile
 | 
			
		||||
echo "iiab-admin-console commit: $HASH2" >> $outfile
 | 
			
		||||
echo >> $outfile
 | 
			
		||||
cat_file /etc/iiab/pr-list-pulled
 | 
			
		||||
cat_file /sys/firmware/devicetree/base/model
 | 
			
		||||
cat_file /etc/rpi-issue
 | 
			
		||||
echo "-IIAB-EXPLANATION-OF-THE-ABOVE-------------------------------------------------" >> $outfile
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,4 +62,4 @@ But first off, the file is compiled by harvesting 1 + 6 kinds of things:
 | 
			
		|||
 | 
			
		||||
## Source Code
 | 
			
		||||
 | 
			
		||||
Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 105-219 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible.
 | 
			
		||||
Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 105-220 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -728,6 +728,9 @@ is_fedora_18: False
 | 
			
		|||
# 4. Likewise behind the scenes:
 | 
			
		||||
#       ./iiab-configure (uses iiab-from-cmdline.yml)
 | 
			
		||||
#       Admin Console (uses iiab-from-console.yml)
 | 
			
		||||
# 5. roles/0-init/tasks/main.yml reads from /etc/ansible/facts.d file(s)
 | 
			
		||||
#    local_facts.facts (but not admin_facts.fact ?)
 | 
			
		||||
# 6. /etc/iiab/iiab.env is created by roles/1-prep/templates/iiab.env.j2
 | 
			
		||||
#
 | 
			
		||||
# More details, including Order of Execution and Precedence:
 | 
			
		||||
# https://github.com/iiab/iiab/wiki/IIAB-Variables
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue