ユーザー名とパスワードを含むAnsible Playbookを使用してWeb URLにログイン/認証する方法

ユーザー名とパスワードを含むAnsible Playbookを使用してWeb URLにログイン/認証する方法

私はAnsible Playbookを初めて使用し、ユーザー名とパスワードを使用してWebサイトのURLにログインしようとしています。私はこの問題に直面しています。以下のコードスニペットを使用しています。誰かが私がそれを実装するのを助けることができればいいでしょう。

パスワード:

     - name: Getting the WP Password
       ansible.builtin.shell: grep -oP '(?<=\bWPPASS=)[^;]+' config.conf
       args:
         chdir: /home/admin/golden/configuration/scripts/conf/
       register: password

     - name: Printing the WP Admin Password
       debug: msg="WPPassword={{password.stdout}}" 
     
     - name: Login to the website url
       uri:
         url: https://{{result.stdout}}.{{ domain }}/wp-admin
         method: POST
         body:
            user: admin
            password: "{{password.stdout}}"
            enter: Sign in
         status_code: 200

私がしようとしているもの:

ユーザー名とパスワードを使用してWordPress wp-adminにログインしようとしています。

私が何を期待しているの?

URL、ユーザー名、パスワードを入力したら、ログインして200ステータスコードを入力する必要があります。

エラーメッセージ

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: can't concat str to bytes
fatal: [ok-example.com]: FAILED! => {"changed": false, "content": "", "elapsed": 0, "msg": "Status code was -1 and not [200]: An unknown error occurred: can't concat str to bytes", "redirected": false, "status": -1, "url": "https://dev.example.com/wp-admin"}

代替ソリューションにも感謝します。

ありがとう

ベストアンサー1

おすすめ記事