adhere to module naming conventions

This commit is contained in:
Jan Christian Grünhage 2020-02-14 12:42:54 +01:00
parent 0b1aa650d8
commit b43403f4f0
10 changed files with 22 additions and 22 deletions

View file

@ -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 }}"
```

View file

@ -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 }}"

View file

@ -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 }}"
'''

View file

@ -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: "<b>hello world</b>"
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: "<b>hello world</b>"
room_id: "!12345678:server.tld"
@ -109,7 +109,7 @@ async def run_module():
)
result = dict(
changed=True,
changed=False,
message=''
)

View file

@ -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 }}"

View file

@ -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:

View file

@ -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

View file

@ -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\": \"<b>Hello, World!</b>\"}}" | 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\": \"<b>Hello, World!</b>\"}}" | python matrix_notification.py`
echo $notification_resp

View file

@ -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

View file

@ -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