diff --git a/README.md b/README.md index dce54e0..ea37599 100644 --- a/README.md +++ b/README.md @@ -24,17 +24,17 @@ For a usage example including all modules, look at the example playbook below. alias: '#some-alias:example.org' message: "Set room name in" tasks: - - matrix-login: + - matrix_login: hs_url: "{{ matrix.homeserver }}" user_id: "{{ matrix.user }}" password: "{{ matrix.password }}" register: login_result - - matrix-room: + - matrix_room: hs_url: "{{ matrix.homeserver }}" token: "{{ login_result.token }}" alias: "{{ matrix.alias }}" register: room_result - - matrix-state: + - matrix_state: hs_url: "{{ matrix.homeserver }}" token: "{{ login_result.token }}" room_id: "{{ room_result.room_id }}" @@ -43,14 +43,14 @@ For a usage example including all modules, look at the example playbook below. content: name: "test room name" register: state_result - - matrix-notification: + - matrix_notification: hs_url: "{{ matrix.homeserver }}" token: "{{ login_result.token }}" room_id: "{{ room_result.room_id }}" msg_plain: "{{ matrix.message }} {{ state_result.event_id}}" msg_html: "{{ matrix.message }} {{ state_result.event_id}}" when: state_result.changed - - matrix-logout: + - matrix_logout: hs_url: "{{ matrix.homeserver }}" token: "{{ login_result.token }}" ``` diff --git a/matrix-login.py b/matrix_login.py similarity index 98% rename from matrix-login.py rename to matrix_login.py index 5bf254d..c17b519 100644 --- a/matrix-login.py +++ b/matrix_login.py @@ -17,7 +17,7 @@ ANSIBLE_METADATA = { DOCUMENTATION = ''' --- author: "Jan Christian Grünhage (@jcgruenhage)" -module: matrix-login +module: matrix_login short_description: Get a matrix access token description: - Log in to a matrix homeserver and get an access token back @@ -40,7 +40,7 @@ requirements: EXAMPLES = ''' - name: Log in to matrix - matrix: + matrix_login: hs_url: "https://matrix.org" user_id: "{{ matrix_auth_user }}" password: "{{ matrix_auth_password }}" diff --git a/matrix-logout.py b/matrix_logout.py similarity index 98% rename from matrix-logout.py rename to matrix_logout.py index 08ac293..952f776 100644 --- a/matrix-logout.py +++ b/matrix_logout.py @@ -17,7 +17,7 @@ ANSIBLE_METADATA = { DOCUMENTATION = ''' --- author: "Jan Christian Grünhage (@jcgruenhage)" -module: matrix +module: matrix_logout short_description: Log out of matrix description: - Invalidate an access token by logging out @@ -36,7 +36,7 @@ requirements: EXAMPLES = ''' - name: Invalidate access token - matrix: + matrix_logout: hs_url: "https://matrix.org" token: "{{ matrix_auth_token }}" ''' diff --git a/matrix-notification.py b/matrix_notification.py similarity index 97% rename from matrix-notification.py rename to matrix_notification.py index edd3852..98523c8 100644 --- a/matrix-notification.py +++ b/matrix_notification.py @@ -17,7 +17,7 @@ ANSIBLE_METADATA = { DOCUMENTATION = ''' --- author: "Jan Christian Grünhage (@jcgruenhage)" -module: matrix-notification +module: matrix_notification short_description: Send notifications to matrix description: - This module sends html formatted notifications to matrix rooms. @@ -54,7 +54,7 @@ requirements: EXAMPLES = ''' - name: Send matrix notification with token - matrix-notification: + matrix_notification: msg_plain: "**hello world**" msg_html: "hello world" room_id: "!12345678:server.tld" @@ -62,7 +62,7 @@ EXAMPLES = ''' token: "{{ matrix_auth_token }}" - name: Send matrix notification with user_id and password - matrix-notification: + matrix_notification: msg_plain: "**hello world**" msg_html: "hello world" room_id: "!12345678:server.tld" @@ -109,7 +109,7 @@ async def run_module(): ) result = dict( - changed=True, + changed=False, message='' ) diff --git a/matrix-room.py b/matrix_room.py similarity index 99% rename from matrix-room.py rename to matrix_room.py index a762903..96c288c 100644 --- a/matrix-room.py +++ b/matrix_room.py @@ -17,7 +17,7 @@ ANSIBLE_METADATA = { DOCUMENTATION = ''' --- author: "Jan Christian Grünhage (@jcgruenhage)" -module: matrix-room +module: matrix_room short_description: Join/Create matrix room description: - This module takes a room alias and makes sure that the user identified by the access token is in such a room. If that room does not exist, it is created, if it does exist but the user is not in it, it tries to join. If the alias is taken and the user can't join the room, the module will fail. Remote aliases are not supported for creating, but work for joining. @@ -39,7 +39,7 @@ requirements: EXAMPLES = ''' - name: Create notification room - matrix-room: + matrix_room: alias: "#ansible-notifications:matrix.org" hs_url: "https://matrix.org" token: "{{ matrix_auth_token }}" diff --git a/matrix-state.py b/matrix_state.py similarity index 99% rename from matrix-state.py rename to matrix_state.py index 05932a2..7a5bf89 100644 --- a/matrix-state.py +++ b/matrix_state.py @@ -17,7 +17,7 @@ ANSIBLE_METADATA = { DOCUMENTATION = ''' --- author: "Jan Christian Grünhage (@jcgruenhage)" -module: matrix +module: matrix_state short_description: Set matrix room state description: - This module sets matrix room state idempotently @@ -52,7 +52,7 @@ requirements: EXAMPLES = ''' - name: Set the server ACL for the admin room - matrix: + matrix_state: event_type: m.room.server_acl state_key: "" content: diff --git a/test-login-logout.sh b/test-login-logout.sh index a4debf7..5da743a 100755 --- a/test-login-logout.sh +++ b/test-login-logout.sh @@ -2,10 +2,10 @@ source test-settings.sh -login_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\",\"user_id\": \"${USER_ID}\",\"password\": \"${PASSWORD}\"}}" | python matrix-login.py` +login_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\",\"user_id\": \"${USER_ID}\",\"password\": \"${PASSWORD}\"}}" | python matrix_login.py` echo $login_resp local_token=`echo $login_resp | jq --raw-output '.token'` -echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\",\"token\": \"${local_token}\"}}" | python matrix-logout.py +echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\",\"token\": \"${local_token}\"}}" | python matrix_logout.py diff --git a/test-notification.sh b/test-notification.sh index 3dc6c53..7925ec1 100755 --- a/test-notification.sh +++ b/test-notification.sh @@ -2,6 +2,6 @@ source test-settings.sh -notification_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\", \"token\": \"${TOKEN}\", \"room_id\": \"${ROOM_ID}\", \"msg_plain\": \"**Hello, World!**\", \"msg_html\": \"Hello, World!\"}}" | python matrix-notification.py` +notification_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\", \"token\": \"${TOKEN}\", \"room_id\": \"${ROOM_ID}\", \"msg_plain\": \"**Hello, World!**\", \"msg_html\": \"Hello, World!\"}}" | python matrix_notification.py` echo $notification_resp diff --git a/test-room.sh b/test-room.sh index 7b36063..2c3d3b0 100755 --- a/test-room.sh +++ b/test-room.sh @@ -2,6 +2,6 @@ source test-settings.sh -room_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\",\"token\": \"${TOKEN}\",\"alias\": \"${ROOM_ALIAS}\"}}" | python matrix-room.py` +room_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\",\"token\": \"${TOKEN}\",\"alias\": \"${ROOM_ALIAS}\"}}" | python matrix_room.py` echo $room_resp diff --git a/test-state.sh b/test-state.sh index 08139b2..5572971 100755 --- a/test-state.sh +++ b/test-state.sh @@ -2,6 +2,6 @@ source test-settings.sh -state_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\", \"token\": \"${TOKEN}\", \"room_id\": \"${ROOM_ID}\", \"state_key\": \"\", \"event_type\": \"m.room.name\", \"content\": { \"name\": \"test room name\"}}}" | python matrix-state.py` +state_resp=` echo "{\"ANSIBLE_MODULE_ARGS\": {\"hs_url\": \"${HS_URL}\", \"token\": \"${TOKEN}\", \"room_id\": \"${ROOM_ID}\", \"state_key\": \"\", \"event_type\": \"m.room.name\", \"content\": { \"name\": \"test room name\"}}}" | python matrix_state.py` echo $state_resp