mirror of
				https://github.com/geerlingguy/ansible-role-certbot.git
				synced 2025-11-04 01:11:12 +01:00 
			
		
		
		
	Do not try to stop services which don't exist yet
This solves a chicken and egg problem where a certificate needed for a service to run does not exist yet and certbot role fails on stopping a service which is not yet installed.
This commit is contained in:
		
							parent
							
								
									6e17af0ac5
								
							
						
					
					
						commit
						cc9c24c195
					
				@ -4,12 +4,15 @@
 | 
				
			|||||||
    path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
 | 
					    path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
 | 
				
			||||||
  register: letsencrypt_cert
 | 
					  register: letsencrypt_cert
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: Populate service facts
 | 
				
			||||||
 | 
					  service_facts:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Stop services to allow certbot to generate a cert.
 | 
					- name: Stop services to allow certbot to generate a cert.
 | 
				
			||||||
  service:
 | 
					  service:
 | 
				
			||||||
    name: "{{ item }}"
 | 
					    name: "{{ item }}"
 | 
				
			||||||
    state: stopped
 | 
					    state: stopped
 | 
				
			||||||
  when: not letsencrypt_cert.stat.exists
 | 
					  when: not letsencrypt_cert.stat.exists
 | 
				
			||||||
  with_items: "{{ certbot_create_standalone_stop_services }}"
 | 
					  with_items: "{{ certbot_create_standalone_stop_services | intersect(services) }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Generate new certificate if one doesn't exist.
 | 
					- name: Generate new certificate if one doesn't exist.
 | 
				
			||||||
  command: "{{ certbot_create_command }}"
 | 
					  command: "{{ certbot_create_command }}"
 | 
				
			||||||
@ -20,4 +23,4 @@
 | 
				
			|||||||
    name: "{{ item }}"
 | 
					    name: "{{ item }}"
 | 
				
			||||||
    state: started
 | 
					    state: started
 | 
				
			||||||
  when: not letsencrypt_cert.stat.exists
 | 
					  when: not letsencrypt_cert.stat.exists
 | 
				
			||||||
  with_items: "{{ certbot_create_standalone_stop_services }}"
 | 
					  with_items: "{{ certbot_create_standalone_stop_services | intersect(services) }}"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user