Fix pre-commit hooks and move directories
roles/ and inventory/ are now in playbooks/ also fixed issues reported by ansible-lint
This commit is contained in:
		
							parent
							
								
									dc398ddb6e
								
							
						
					
					
						commit
						4104057771
					
				
					 123 changed files with 91 additions and 39 deletions
				
			
		
							
								
								
									
										43
									
								
								playbooks/roles/healthcheck/files/data/matrix
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								playbooks/roles/healthcheck/files/data/matrix
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
#!/usr/bin/python3
 | 
			
		||||
 | 
			
		||||
import datetime
 | 
			
		||||
import os
 | 
			
		||||
import requests
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
import asyncio
 | 
			
		||||
from nio import AsyncClient, RoomMessageNotice
 | 
			
		||||
 | 
			
		||||
def send_ping(success, msg=""):
 | 
			
		||||
    url = os.environ['MATRIX_HC_URL']
 | 
			
		||||
    if not success:
 | 
			
		||||
        url += "/fail"
 | 
			
		||||
 | 
			
		||||
    requests.get(url, data=msg, headers={'user-agent': os.environ['USER_AGENT']})
 | 
			
		||||
 | 
			
		||||
async def main():
 | 
			
		||||
    try:
 | 
			
		||||
        client = AsyncClient(os.environ['MATRIX_SERVER'])
 | 
			
		||||
        client.access_token = os.environ['MATRIX_TOKEN']
 | 
			
		||||
        client.device_id = os.environ['USER_AGENT']
 | 
			
		||||
        await client.room_send(
 | 
			
		||||
            room_id = os.environ['MATRIX_ROOM'],
 | 
			
		||||
            message_type = "m.room.message",
 | 
			
		||||
            content = {
 | 
			
		||||
                "msgtype": "m.text",
 | 
			
		||||
                "body": "!ping"
 | 
			
		||||
            }
 | 
			
		||||
        )
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        print(e)
 | 
			
		||||
 | 
			
		||||
        print("exception during login or sending")
 | 
			
		||||
        send_ping(False, str(e))
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    await client.close()
 | 
			
		||||
 | 
			
		||||
    send_ping(True)
 | 
			
		||||
    sys.exit(0)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
asyncio.new_event_loop().run_until_complete(main())
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue