ansible – 内联加密变量,不是JSON可序列化的

前端之家收集整理的这篇文章主要介绍了ansible – 内联加密变量,不是JSON可序列化的前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图了解如何使用保险库加密单个变量.首先,我使用ansible-vault encrypt_string -n -p加密字符串,然后将输出写入我的playbook.当我执行playbook时,它说解密的字符串不是 JSON可序列化的.

加密字符串:“inline_name”
我也尝试使用inline_name和inlinename,每次都有相同的结果.

我的剧本:

---
- name: Build System

  hosts: dev

  tasks:
  - name: Create 
    MysqL_db:
      state: present
      name: !vault |
          $ANSIBLE_VAULT;1.1;AES256
          39613261386438623937643062636166663638633062323939343734306334346537613233623064
          3761633832326365356231633338396132646532313861350a316666376566616633376238313636
          39343833306462323534623238333639663734626662623731666239366566643636386261643164
          3861363730336331660a316165633232323732633364346636363764623639356562336536636136
          6364
      login_host: "{{ MysqL_host }}"
      login_user: "{{ MysqL_user }}"
      login_password: "{{ MysqL_pass }}"
  - name: Check if can access plain text vars
    debug:
      msg: "{{ my_plain_txt }}"

错误信息:

An exception occurred during task execution. To see the full traceback,use -vvv. 
The error was: TypeError: u'"inline_name"' is not JSON serializable
fatal: [127.0.0.1]: Failed! => {"Failed": true,"msg": "Unexpected failure during module execution.","stdout": ""}

解决方法

添加任务级变量:
- name: Create 
    MysqL_db:
      state: present
      name: "{{ MysqL_name }}"
      login_host: "{{ MysqL_host }}"
      login_user: "{{ MysqL_user }}"
      login_password: "{{ MysqL_pass }}"
    vars:
      MysqL_name: !vault |
          $ANSIBLE_VAULT;1.1;AES256
          39613261386438623937643062636166663638633062323939343734306334346537613233623064
          3761633832326365356231633338396132646532313861350a316666376566616633376238313636
          39343833306462323534623238333639663734626662623731666239366566643636386261643164
          3861363730336331660a316165633232323732633364346636363764623639356562336536636136
          6364
原文链接:https://www.f2er.com/js/150047.html

猜你在找的JavaScript相关文章