I’m working on an Ansible script to create items in 1Password using the CLI (op command), but I’m encountering an issue that I can’t resolve. When I run the playbook, I receive the following error: [ERROR] 2024/08/15 14:06:06 invalid JSON in piped input. The relevant part of my playbook includes authenticating with 1Password using the op signin command, which works fine, and then attempting to create a new item with the op item create command. The environment variable OP_SERVICE_ACCOUNT_TOKEN is set correctly, and the op item create command works perfectly when run directly from the command line. However, it fails with the JSON error mentioned above when executed through Ansible. I’m unsure why this is happening and how to fix it. Any guidance or suggestions would be greatly appreciated.
It appears to me as though this cannot work: you are evaluating the result of a command in a task, and I get the feeling you’re assuming that result (probably in the form of environment variables) is available in the second invocation of the shell module. It is not.
These two tasks are independent of eachother and will always be so. If the result of the first (which you’ve registered in op_signin) needs to be given to the second, then you have to do that explicitly.
As an aside: I trust the double asterisks (**) I’m seeing are an artifact of the paste.
You might also wish to use your favorite search engine to find something more solid, maybe a module which does that. My search engine returns plenty of results.
Hello , thank you for the answer . “As an aside: I trust the double asterisks (** ) I’m seeing are an artifact of the paste.” yes this is a typo added automatically from the code format. There is another solution using connect server for example this solution ansible-onepasswordconnect-collection/USAGEGUIDE.md at main · 1Password/ansible-onepasswordconnect-collection · GitHub . But the problem that I don’t have local server my. My 1 password account is using amazon cloud.