add an optional post-commit hook to send a commit email
This commit is contained in:
		
							parent
							
								
									2a7e40c3d6
								
							
						
					
					
						commit
						e642e54912
					
				
					 3 changed files with 25 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -14,3 +14,12 @@ roles:
 | 
			
		|||
    - { role: etckeeper,                    tags: ['system', 'etckeeper'],
 | 
			
		||||
        avoid_autocommits: true }
 | 
			
		||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 | 
			
		||||
 | 
			
		||||
To send commit emails to root:
 | 
			
		||||
 | 
			
		||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 | 
			
		||||
roles:
 | 
			
		||||
    - { role: etckeeper,                    tags: ['system', 'etckeeper'],
 | 
			
		||||
        avoid_autocommits: true,
 | 
			
		||||
        etckeeper_mailto: root }
 | 
			
		||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,3 +29,9 @@
 | 
			
		|||
- file: path=/etc/.bzr state=absent
 | 
			
		||||
- name: "etckeeper: Initialize"
 | 
			
		||||
  command: etckeeper init creates=/etc/.git/
 | 
			
		||||
 | 
			
		||||
- name: enable etckeeper commit mails
 | 
			
		||||
  template: src=post-commit-mail.j2
 | 
			
		||||
            dest=/etc/.git/hooks/post-commit
 | 
			
		||||
            mode=0755
 | 
			
		||||
  when: etckeeper_mailto is defined
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								templates/post-commit-mail.j2
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								templates/post-commit-mail.j2
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
HOSTNAME=`hostname --fqdn`
 | 
			
		||||
MAILTO={{ etckeeper_mailto }}
 | 
			
		||||
 | 
			
		||||
# (echo "Diffstat:" ; git show | diffstat ; echo -e "\nDiff:" ; \
 | 
			
		||||
# git show | filterdiff -x '**/*shadow*' -x '**/*.key' -x '**/private/*' ) \
 | 
			
		||||
#        | mail -s "etckeeper $HOSTNAME" $MAILTO
 | 
			
		||||
 | 
			
		||||
git show --stat | mail -s "etckeeper $HOSTNAME" $MAILTO
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue