Slide 25
Slide 25 text
Python de ࣮
#!/usr/bin/python
import os
def main():
fields = { "file_name": { "required": True, "type": "str" } }
module = AnsibleModule(argument_spec=fields, supports_check_mode=True)
if os.path.exists('/tmp/' + module.params['file_name']):
module.exit_json(changed=False)
else:
open('/tmp/' + module.params['file_name'], 'w').close()
if os.path.exists('/tmp/' + module.params['file_name']):
module.exit_json(changed=True)
else:
module.fail_json(msg='Error.')
from ansible.module_utils.basic import *
if __name__ == '__main__':
main()
25 CIRASUʢ͠Β͢ʣAnsible పఈೖ ྠಡձ #0