提供语法错误的自定义Ansible模块

问题描述 投票:-1回答:1

我正在尝试使用Python 3编写我的第一个ansible模块。我正在尝试使用uname命令获取系统信息。

代码:

#!/usr/bin/python3

from ansible.module_utils.basic import *

def main():

    module = AnsibleModule(argument_spec={})
    rc, out, err = module.run_command(['/usr/bin/uname')
    module.exit_json(changed=False, meta=out)

if __name__ == "__main__":

    main()

我得到的错误如下:

node1 | FAILED! => {
    "msg": "Unable to import kernel.py due to invalid syntax"
}

我知道有什么问题,但无法弄清楚这是什么。而且,有关在何处阅读有关编写自己的Ansible模块的更多信息的任何建议都将大有帮助。谢谢。

python python-3.x ansible ansible-2.x ansible-module
1个回答
0
投票
 rc, out, err = module.run_command(['/usr/bin/uname')
                                                       ^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
© www.soinside.com 2019 - 2024. All rights reserved.