mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			55 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
# "How do i fail a task in Ansible if the variable contains a boolean value?
 | 
						|
# I want to perform input validation for Ansible playbooks"
 | 
						|
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
 | 
						|
 | 
						|
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
 | 
						|
# to re-check whether vars are defined here.  As Ansible vars cannot be unset:
 | 
						|
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
 | 
						|
 | 
						|
- name: Assert that "gitea_install is sameas true" (boolean not string etc)
 | 
						|
  assert:
 | 
						|
    that: gitea_install is sameas true
 | 
						|
    fail_msg: "PLEASE SET 'gitea_install: True' e.g. IN: /etc/iiab/local_vars.yml"
 | 
						|
    quiet: yes
 | 
						|
 | 
						|
- name: Assert that "gitea_enabled | type_debug == 'bool'" (boolean not string etc)
 | 
						|
  assert:
 | 
						|
    that: gitea_enabled | type_debug == 'bool'
 | 
						|
    fail_msg: "PLEASE GIVE VARIABLE 'gitea_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
 | 
						|
    quiet: yes
 | 
						|
 | 
						|
 | 
						|
- block:
 | 
						|
 | 
						|
  - name: Install Gitea {{ gitea_version }} if 'gitea_installed' not defined, e.g. in {{ iiab_state_file }}    # /etc/iiab/iiab_state.yml
 | 
						|
    include_tasks: install.yml
 | 
						|
    when: gitea_installed is undefined
 | 
						|
 | 
						|
  - include_tasks: enable-or-disable.yml
 | 
						|
 | 
						|
  - name: Add 'gitea' to list of services at {{ iiab_ini_file }}
 | 
						|
    ini_file:
 | 
						|
      path: "{{ iiab_ini_file }}"    # /etc/iiab/iiab.ini
 | 
						|
      section: gitea
 | 
						|
      option: "{{ item.option }}"
 | 
						|
      value: "{{ item.value | string }}"
 | 
						|
    with_items:
 | 
						|
      - option: name
 | 
						|
        value: Gitea
 | 
						|
      - option: description
 | 
						|
        value: '"Gitea is like GitHub for more offline communities: Git with a cup of tea"'
 | 
						|
      - option: gitea_install
 | 
						|
        value: "{{ gitea_install }}"
 | 
						|
      - option: gitea_enabled
 | 
						|
        value: "{{ gitea_enabled }}"
 | 
						|
      - option: gitea_run_directory
 | 
						|
        value: "{{ gitea_run_directory }}"
 | 
						|
      - option: gitea_url
 | 
						|
        value: "{{ gitea_url }}"
 | 
						|
 | 
						|
  rescue:
 | 
						|
 | 
						|
  - name: 'SEE ERROR ABOVE (skip_role_on_error: {{ skip_role_on_error }})'
 | 
						|
    fail:
 | 
						|
      msg: ""
 | 
						|
    when: not skip_role_on_error
 |