1password ansible script for login and edit the password

303 Views Asked by At

My aim to auto login and edit the password.

Tried this script

---
- name: Get device information
  hosts: localhost
  connection: local

  vars:
    one_pass_signinaddress: "https://xxxxx.1password.com"
    one_pass_emailaddress: "[email protected]"
    one_pass_secretkey: "xxxxxxyyy"
    one_pass_master_password: "xxxxx"


  tasks: 
    - name: Login one_pass
      shell: "op signin {{ one_pass_signinaddress }} {{ one_pass_emailaddress }} {{ one_pass_secretkey }} {{ one_pass_master_password }} --output=raw"
      register: op_session
    
    - name: Edit Password
      shell: op edit item "Test" password=qweqwe23424
      register: op_edit

Its gives this error

accepts at most 3 arg(s), received 4
1

There are 1 best solutions below

0
On

From the documentation, it looks like you don't pass your secret key and password on the commandline, just the URL and your email address. Then it will prompt you for the secrets. I haven't used the tool myself, let alone via Ansible, so I can't offer a solid approach to get it to work, but it might be possible using the stdin argument on the shell task or otherwise using an expect script.