mirror of
https://github.com/zahodi/ansible-mikrotik.git
synced 2025-07-30 07:34:47 +02:00
add the module collection
This commit is contained in:
parent
3609e520c5
commit
428dd5e0e2
22 changed files with 3741 additions and 0 deletions
41
library/mt_login_test.py
Normal file
41
library/mt_login_test.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
import json
|
||||
import mt_api
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
hostname=dict(required=True),
|
||||
username=dict(required=True),
|
||||
password=dict(required=True),
|
||||
)
|
||||
)
|
||||
|
||||
hostname = module.params['hostname']
|
||||
username = module.params['username']
|
||||
password = module.params['password']
|
||||
changed = False
|
||||
msg = ""
|
||||
|
||||
mk = mt_api.Mikrotik(hostname,username,password)
|
||||
try:
|
||||
mk.login()
|
||||
except:
|
||||
module.fail_json(
|
||||
msg="Could not log into Mikrotik device. Check the username and password."
|
||||
)
|
||||
|
||||
|
||||
# response = apiros.talk([b'/ip/address/add', b'=address=192.168.15.2/24', b'=interface=ether7'])
|
||||
module.exit_json(
|
||||
changed=False,
|
||||
failed=False,
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue