guix_package.py 840 B

12345678910111213141516171819202122232425262728
  1. import json
  2. import os
  3. from ansible.module_utils.basic import AnsibleModule
  4. def main():
  5. module = AnsibleModule(
  6. argument_spec=dict(
  7. load_path=dict(type="str", required=True),
  8. manifest=dict(type="str", required=True),
  9. profile=dict(type="str", required=True)
  10. )
  11. )
  12. before = os.path.realpath(module.params['profile'])
  13. result = module.run_command(f"guix package --fallback --load-path={module.params['load_path']} --manifest={module.params['manifest']}")
  14. after = os.path.realpath("/home/oleg/.guix-profile")
  15. result = {
  16. "msg": {"before": before, "after": after},
  17. "rc:": result if result[0] != 0 else after,
  18. "failed": result[0] != 0,
  19. "changed": before != after,
  20. }
  21. module.exit_json(**result)
  22. if __name__ == "__main__":
  23. main()