mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 09:12:11 +01:00 
			
		
		
		
	Merge branch 'ansible-fix' into 'beta'
Ansible fix See merge request bde/nk20!139
This commit is contained in:
		@@ -3,3 +3,4 @@ note:
 | 
			
		||||
  server_name: note-beta.crans.org
 | 
			
		||||
  git_branch: beta
 | 
			
		||||
  cron_enabled: false
 | 
			
		||||
  email: notekfet2020@lists.crans.org
 | 
			
		||||
 
 | 
			
		||||
@@ -3,3 +3,4 @@ note:
 | 
			
		||||
  server_name: note-dev.crans.org
 | 
			
		||||
  git_branch: beta
 | 
			
		||||
  cron_enabled: false
 | 
			
		||||
  email: notekfet2020@lists.crans.org
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,12 @@
 | 
			
		||||
  apt_repository:
 | 
			
		||||
    repo: deb http://{{ mirror }}/debian buster-backports main
 | 
			
		||||
    state: present
 | 
			
		||||
  when: ansible_facts['distribution'] == "Debian"
 | 
			
		||||
 | 
			
		||||
- name: Install note_kfet APT dependencies
 | 
			
		||||
  apt:
 | 
			
		||||
    update_cache: true
 | 
			
		||||
    default_release: buster-backports
 | 
			
		||||
    default_release: "{{ 'buster-backports' if ansible_facts['distribution'] == 'Debian' }}"
 | 
			
		||||
    install_recommends: false
 | 
			
		||||
    name:
 | 
			
		||||
      # Common tools
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
 | 
			
		||||
- name: Use default env vars (should be updated!)
 | 
			
		||||
  template:
 | 
			
		||||
    src: "env_example"
 | 
			
		||||
    src: "env.j2"
 | 
			
		||||
    dest: "/var/www/note_kfet/.env"
 | 
			
		||||
    mode: 0644
 | 
			
		||||
    force: false
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								ansible/roles/2-nk20/templates/env.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								ansible/roles/2-nk20/templates/env.j2
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
DJANGO_APP_STAGE=prod
 | 
			
		||||
# Only used in dev mode, change to "postgresql" if you want to use PostgreSQL in dev
 | 
			
		||||
DJANGO_DEV_STORE_METHOD=sqlite
 | 
			
		||||
DJANGO_DB_HOST=localhost
 | 
			
		||||
DJANGO_DB_NAME=note_db
 | 
			
		||||
DJANGO_DB_USER=note
 | 
			
		||||
DJANGO_DB_PASSWORD={{ DB_PASSWORD }}
 | 
			
		||||
DJANGO_DB_PORT=
 | 
			
		||||
DJANGO_SECRET_KEY=CHANGE_ME
 | 
			
		||||
DJANGO_SETTINGS_MODULE=note_kfet.settings
 | 
			
		||||
CONTACT_EMAIL=tresorerie.bde@localhost
 | 
			
		||||
NOTE_URL= {{note.server_name}}
 | 
			
		||||
 | 
			
		||||
# Config for mails. Only used in production
 | 
			
		||||
NOTE_MAIL=notekfet@localhost
 | 
			
		||||
EMAIL_HOST=smtp.localhost
 | 
			
		||||
EMAIL_PORT=25
 | 
			
		||||
EMAIL_USER=notekfet@localhost
 | 
			
		||||
EMAIL_PASSWORD=CHANGE_ME
 | 
			
		||||
 | 
			
		||||
# Wiki configuration
 | 
			
		||||
WIKI_USER=NoteKfet2020
 | 
			
		||||
WIKI_PASSWORD=
 | 
			
		||||
@@ -9,6 +9,11 @@
 | 
			
		||||
  retries: 3
 | 
			
		||||
  until: pkg_result is succeeded
 | 
			
		||||
 | 
			
		||||
- name: Check if certificate already exists.
 | 
			
		||||
  stat:
 | 
			
		||||
    path: /etc/letsencrypt/live/{{note.server_name}}/cert.pem
 | 
			
		||||
  register: letsencrypt_cert
 | 
			
		||||
 | 
			
		||||
- name: Create /etc/letsencrypt/conf.d
 | 
			
		||||
  file:
 | 
			
		||||
    path: /etc/letsencrypt/conf.d
 | 
			
		||||
@@ -19,3 +24,17 @@
 | 
			
		||||
    src: "letsencrypt/conf.d/nk20.ini.j2"
 | 
			
		||||
    dest: "/etc/letsencrypt/conf.d/nk20.ini"
 | 
			
		||||
    mode: 0644
 | 
			
		||||
 | 
			
		||||
- name: Stop services to allow certbot to generate a cert.
 | 
			
		||||
  service:
 | 
			
		||||
    name: nginx
 | 
			
		||||
    state: stopped
 | 
			
		||||
 | 
			
		||||
- name: Generate new certificate if one doesn't exist.
 | 
			
		||||
  shell: "certbot certonly --non-interactive --config /etc/letsencrypt/conf.d/nk20.ini -d {{note.server_name}}"
 | 
			
		||||
  when: letsencrypt_cert.stat.exists == False
 | 
			
		||||
 | 
			
		||||
- name: Restart services to allow certbot to generate a cert.
 | 
			
		||||
  service:
 | 
			
		||||
    name: nginx
 | 
			
		||||
    state: started
 | 
			
		||||
 
 | 
			
		||||
@@ -10,11 +10,11 @@ rsa-key-size = 4096
 | 
			
		||||
# server = https://acme-staging.api.letsencrypt.org/directory
 | 
			
		||||
 | 
			
		||||
# Uncomment and update to register with the specified e-mail address
 | 
			
		||||
email = notekfet2020@lists.crans.org
 | 
			
		||||
email = {{ note.email }}
 | 
			
		||||
 | 
			
		||||
# Uncomment to use a text interface instead of ncurses
 | 
			
		||||
text = True
 | 
			
		||||
 | 
			
		||||
# Use DNS-01 challenge
 | 
			
		||||
authenticator = nginx
 | 
			
		||||
authenticator = standalone
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,14 +11,14 @@
 | 
			
		||||
  until: pkg_result is succeeded
 | 
			
		||||
 | 
			
		||||
- name: Create role note
 | 
			
		||||
  when: "DB_PASSWORD|bool"    # If the password is not defined, skip the installation
 | 
			
		||||
  when: DB_PASSWORD|length > 0 # If the password is not defined, skip the installation
 | 
			
		||||
  postgresql_user:
 | 
			
		||||
    name: note
 | 
			
		||||
    password: "{{ DB_PASSWORD }}"
 | 
			
		||||
  become_user: postgres
 | 
			
		||||
 | 
			
		||||
- name: Create NK20 database
 | 
			
		||||
  when: "DB_PASSWORD|bool"
 | 
			
		||||
  when: DB_PASSWORD|length >0
 | 
			
		||||
  postgresql_db:
 | 
			
		||||
    name: note_db
 | 
			
		||||
    owner: note
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user