{"id":42865,"date":"2023-07-24T03:08:23","date_gmt":"2023-01-13T01:57:50","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/"},"modified":"2024-04-30T15:03:08","modified_gmt":"2024-04-30T07:03:08","slug":"ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/","title":{"rendered":"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801"},"content":{"rendered":"<h1>\u9996\u5148<\/h1>\n<p>\u4eceAnsible 2.4\u7248\u672c\u5f00\u59cb\uff0c\u901a\u8fc7Ansible Vault\uff0c\u5373\u4f7f\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u7801A\u548c\u5bc6\u7801B\u5bf9\u6587\u4ef6\u8fdb\u884c\u4e86\u5355\u72ec\u7684\u52a0\u5bc6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u547d\u4ee4\u8fdb\u884c\u89e3\u5bc6\u3002\u8fd9\u5728\u5b98\u65b9\u6587\u6863\u7684\u300c\u4f7f\u7528encrypt_string\u5728yaml\u4e2d\u521b\u5efa\u52a0\u5bc6\u53d8\u91cf\u300d\u3001\u300cVault Ids\u548c\u591a\u4e2aVault\u5bc6\u7801\u300d\u4ee5\u53ca\u300c\u63d0\u4f9bVault\u5bc6\u7801\u300d\u7b49\u90e8\u5206\u6709\u8be6\u7ec6\u8bf4\u660e\u3002<\/p>\n<h1>\u8bf7\u6982\u8ff0<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">2.4\u304b\u3089\u3082\u5f93\u6765\u306e&#8211;vault-password-file\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u4f7f\u3048\u308b\u304c\u3001\u4ee3\u308f\u308a\u306b&#8211;vault-id\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u7f6e\u304d\u63db\u3048\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">&#8211;vault-id\u30aa\u30d7\u30b7\u30e7\u30f3\u306f&#8211;vault-password-file\u30aa\u30d7\u30b7\u30e7\u30f3\u4ee5\u4e0a\u306e\u6a5f\u80fd\u3092\u6301\u3063\u3066\u3044\u308b\u304c\u3001\u3068\u308a\u3042\u3048\u305a&#8211;vault-password-file\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u540c\u69d8\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u66f8\u304b\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3059\u308c\u3070&#8211;vault-password-file\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u540c\u3058\u632f\u308b\u821e\u3044\u3092\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u5fa9\u53f7\u306e\u969b\u306b\u306f&#8211;vault-id\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8907\u6570\u56de\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u5225\u3005\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3067\u6697\u53f7\u5316\u3055\u308c\u305f\u8907\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u5834\u5408\u3067\u3082playbook\u306e\u5b9f\u884c\u7b49\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">2.4\u306b\u304a\u3044\u3066\u306f2.3\u307e\u3067\u3068\u6bd4\u3079\u3066\u5b09\u3057\u3044\u3053\u3068\u306f\u3042\u307e\u308a\u306a\u3044\u304c\u3001\u5c06\u6765\u306f\u3082\u3063\u3068\u9762\u767d\u3044\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/ul>\n<h1>2.3\u7684\u8303\u56f4\u5185\u7684\u4e8b\u60c5<\/h1>\n<p>\u4ee5\u524d\uff0c\u6211\u4eec\u4f7f\u7528&#8211;vault-password-file\u9009\u9879\u6765\u6307\u5b9a\u5305\u542bAnsible Vault\u52a0\u5bc6\u548c\u89e3\u5bc6\u5bc6\u7801\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u7f16\u8f91\u5668\u6765\u63cf\u8ff0\u52a0\u5bc6\u6587\u4ef6\u7684\u5185\u5bb9\u7684\u8bdd\uff0c<\/p>\n<pre class=\"post-pre\"><code>$ ansible-vault create --vault-password-file (\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u66f8\u304b\u308c\u305f\u30d5\u30a1\u30a4\u30eb) (\u6697\u53f7\u5316\u3059\u308b\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb)\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8981\u52a0\u5bc6\u73b0\u6709\u7684\u975e\u52a0\u5bc6\u6587\u4ef6\uff0c\u53ef\u4ee5\u8fd9\u6837\u505a<\/p>\n<pre class=\"post-pre\"><code>$ ansible-vault encrypt --vault-password-file (\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u66f8\u304b\u308c\u305f\u30d5\u30a1\u30a4\u30eb) (\u6697\u53f7\u5316\u3059\u308b\u65e2\u5b58\u306e\u672a\u6697\u53f7\u5316\u30d5\u30a1\u30a4\u30eb)\r\n<\/code><\/pre>\n<p>\u5982\u679c\u60f3\u8981\u4ece\u6807\u51c6\u8f93\u5165\u76f4\u63a5\u521b\u5efa\u52a0\u5bc6\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>$ echo -n '(\u30ad\u30fc): (\u5024)' | ansible-vault encrypt --vault-password-file (\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u66f8\u304b\u308c\u305f\u30d5\u30a1\u30a4\u30eb) --output (\u6697\u53f7\u5316\u3059\u308b\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb)\r\n<\/code><\/pre>\n<p>\u5982\u679c\u662f\u90a3\u6837\u7684\u8bdd\u5c31\u597d\u4e86\u3002<\/p>\n<p>\u5982\u679c\u9700\u8981\u89e3\u5bc6\u6216\u67e5\u770b\u65f6\uff0c\u5c31\u9700\u8981\u8fdb\u884c\u89e3\u5bc6\u5904\u7406\uff0c\u5982ansible-vault decrypt\u6216view\uff0c\u6216\u8005\u5728\u4f7f\u7528ansible-playbook\u7b49\u8fdb\u884c\u52a0\u5bc6\u6587\u4ef6\u65f6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528&#8211;vault-password-file\u9009\u9879\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u5982\u679c\u4e0d\u4f7f\u7528&#8211;vault-password-file\u9009\u9879\uff0c\u5728ansible-vault\u547d\u4ee4\u4e2d\u4f1a\u81ea\u52a8\u8981\u6c42\u8f93\u5165\u5bc6\u7801\uff0c\u800c\u5728\u4f7f\u7528ansible-playbook\u7b49\u547d\u4ee4\u65f6\u53ef\u4ee5\u6dfb\u52a0&#8211;ask-vault-pass\u9009\u9879\u6765\u5728\u8fd0\u884c\u65f6\u8981\u6c42\u8f93\u5165\u5bc6\u7801\u3002<\/p>\n<p>\u53ef\u4ee5\u5c06vault-password-file\u9009\u9879\u7684\u503c\u914d\u7f6e\u4e3aansible.cfg\u6587\u4ef6\u4e2d\u7684[defaults]\u90e8\u5206\u4e2d\u7684vault_password_file\uff0c\u6216\u8005\u5c06\u73af\u5883\u53d8\u91cfANSIBLE_VAULT_PASSWORD_FILE\u8bbe\u7f6e\u4e3a\u76f8\u540c\u7684\u503c\uff0c\u90fd\u80fd\u8fbe\u5230\u76f8\u540c\u7684\u6548\u679c\u3002<\/p>\n<h1>\u4ece2.4\u5f00\u59cb\u8bf4<\/h1>\n<p>2.4\u7248\u4ee5\u540e\uff0c\u539f\u5148\u53ef\u7528\u7684\u529f\u80fd\u4ecd\u7136\u53ef\u7528\uff0c\u540c\u65f6\u65b0\u589e\u4e86\u4e00\u4e2a\u540d\u4e3a&#8211;vault-id\u7684\u9009\u9879\u3002<\/p>\n<p>\u5c06\u4e4b\u524d\u6307\u5b9a\u7684&#8211;vault-password-file\u9009\u9879\u66ff\u6362\u4e3a&#8211;vault-id\u9009\u9879\uff0c\u7ed3\u679c\u5c06\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n<p>\u4e3a\u4e86\u9a8c\u8bc1\uff0c\u6211\u4eec\u5728\u8fd9\u91cc\u521b\u5efa\u4e24\u4e2a\u5e26\u6709\u5bc6\u7801\u7684\u6587\u4ef6\uff0c\u547d\u4ee4\u4e3aecho -n &#8220;password1&#8221; &gt; vault_multi_pass1 \u548c echo -n &#8220;password2&#8221; &gt; vault_multi_pass2\u3002<\/p>\n<p>\u4ece\u5148\u524d\u63d0\u5230\u7684\u6807\u51c6\u8f93\u5165\u76f4\u63a5\u521b\u5efa\u52a0\u5bc6\u6587\u4ef6\u7684\u547d\u4ee4\u3002<\/p>\n<pre class=\"post-pre\"><code>$ echo -n 'key1: value1a' | ansible-vault encrypt --vault-password-file vault_multi_pass1 --output host_vars\/multi_pass_host1.yml\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u7684\u547d\u4ee4\u53ef\u4ee5\u5c06 &#8211;vault-password-file \u66ff\u6362\u4e3a &#8211;vault-id \u5e76\u6210\u529f\u6267\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ echo -n 'key1: value1a' | ansible-vault encrypt --vault-id vault_multi_pass1 --output host_vars\/multi_pass_host1.yml\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u662f\u52a0\u5bc6\u6587\u4ef6host_vars\/multi_pass_host1.yml\u7684\u5185\u5bb9\u3002\uff08\u4ece633\u5f00\u59cb\u7684\u52a0\u5bc6\u90e8\u5206\uff0c\u5373\u4f7f\u6253\u51fa\u76f8\u540c\u7684\u547d\u4ee4\uff0c\u7ed3\u679c\u4e5f\u4e0d\u4e00\u5b9a\u4f1a\u5f97\u5230\u76f8\u540c\u7684\u5b57\u7b26\u4e32\uff09<\/p>\n<pre class=\"post-pre\"><code>$ANSIBLE_VAULT;1.1;AES256\r\n63333233346130323433646534383862623633383130366566636563666663363762396165366636\r\n3061376431346533663362333665333037383462303637320a343838393230636463383162313334\r\n65653333366439356638376634313464313033636266616638323934303437626164643630373637\r\n6139363863353163370a303062346163643039663332306538356665313231653364323937656162\r\n6661\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u4f7f\u7528ansible-vault view &#8211;vault-password-file vault_multi_pass1 host_vars\/multi_pass_host1.yml\u6216\u8005ansible-vault view &#8211;vault-id vault_multi_pass1 host_vars\/multi_pass_host1.yml\u6765\u67e5\u770b\u89e3\u5bc6\u540e\u7684\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u4f7f\u7528\u4e86&#8211;vault-id\u9009\u9879\u4e0e\u4ee5\u524d\u6709\u4e86\u4e09\u4e2a\u4e0d\u540c\u4e4b\u5904\u3002<\/p>\n<h2>\u65b0\u529f\u80fd: \u6807\u7b7e<\/h2>\n<p>\u9996\u5148\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728\u503c\u4e2d\u6307\u5b9a&#8221;(\u6807\u7b7e)@(\u5b58\u50a8\u5bc6\u7801\u7684\u6587\u4ef6\u8def\u5f84)&#8221;\u6765\u8bbe\u7f6e\u6807\u7b7e\uff0c\u5373&#8211;vault-id\u9009\u9879\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0c\u5f53\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u6267\u884c\u65f6\uff0c\u52a0\u5bc6\u7684\u6587\u4ef6host_vars\/multi_pass_host2.yml\u5c06\u88ab\u8bbe\u7f6e\u6807\u7b7elabel2\u3002<\/p>\n<pre class=\"post-pre\"><code>$ echo -n 'key1: value1b' | ansible-vault encrypt --vault-id label2@vault_multi_pass1 --output host_vars\/multi_pass_host2.yml\r\n<\/code><\/pre>\n<p>multi_pass_host2.yml\u7684\u5185\u5bb9\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>$ANSIBLE_VAULT;1.2;AES256;label2\r\n39323837616639616662323335353834396338613538383962306562316661323066626463303030\r\n3332646563343637616430643632653233373139643333310a663765633566643531343730636137\r\n65666330323762366431633839343063636636356261653761363763653436313436623864663439\r\n3066313631643166660a346530336461393566623566303166343362386363356338353336613265\r\n3736\r\n<\/code><\/pre>\n<p>host_vars\/multi_pass_host1.yml\u548c\u6ca1\u6709\u6807\u7b7e\u7684host_vars\/multi_pass_host1.yml\u4e4b\u95f4\u7684\u533a\u522b\u5728\u4e8e\uff0c\u6807\u5934\u90e8\u5206\u7684$ANSIBLE_VAULT;\u540e\u9762\u7684\u90e8\u5206\uff0c\u5982\u679c\u6ca1\u6709\u6807\u7b7e\uff0c\u5219\u4e3a1.1\uff0c\u5982\u679c\u6709\u6807\u7b7e\uff0c\u5219\u4e3a1.2\u3002\u8fd9\u662fAnsible Vault\u683c\u5f0f\u7684\u7248\u672c\u53f7\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u53ef\u4ee5\u770b\u5230\u5728AES256\u4e4b\u540e\u6dfb\u52a0\u4e86&#8221;label2&#8243;\u3002 \u8fd9\u662f\u4e00\u4e2a\u6807\u7b7e\u3002<\/p>\n<p>\u5f53\u524d\uff0c\u6807\u7b7e\u53ea\u5728ansible.cfg\u6587\u4ef6\u4e2d\u7684[defaults]\u90e8\u5206\u8bbe\u7f6e\u4e86vault_id_match = True\uff0c\u6216\u8005\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u8bbe\u7f6e\u4e86ANSIBLE_VAULT_ID_MATCH=True\u65f6\u624d\u5177\u6709\u610f\u4e49\u3002\uff08\u9ed8\u8ba4\u4e3aFalse\uff09<\/p>\n<p>\u5982\u679c\u8bbe\u5b9a\u503c\u4e3a False\uff0c\u5219\u4f1a\u5ffd\u7565\u6807\u7b7e\uff1b\u5982\u679c\u8bbe\u5b9a\u4e3a True\uff0c\u5219\u53ea\u4f1a\u89e3\u5bc6\u4e0e\u6307\u5b9a\u6807\u7b7e\u548c\u6587\u4ef6\u4e2d\u5199\u5165\u7684\u5bc6\u7801\u76f8\u5339\u914d\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u7531\u4e8e\u6807\u7b7e\u672c\u8eab\u5e76\u672a\u52a0\u5bc6\uff0c\u6839\u636e\u6211\u5728\u672c\u5730\u6d4b\u8bd5\u7684\u9650\u5236\uff0c\u4f3c\u4e4e\u53ef\u4ee5\u4f7f\u7528\u9002\u5f53\u7684\u7f16\u8f91\u5668\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<h2>\u65b0\u529f\u80fd\uff1a\u4f7f\u7528\u591a\u4e2a\u5bc6\u7801\u8fdb\u884c\u89e3\u5bc6\u3002<\/h2>\n<p>\u5176\u6b21\uff0c\u5982\u679c\u8981\u89e3\u5bc6\uff0c\u53ef\u4ee5\u591a\u6b21\u4f7f\u7528-vault-id\u9009\u9879\u8fdb\u884c\u6307\u5b9a\u3002<\/p>\n<p>\u5728\u6b64\u5904\u4e3a\u4e86\u9a8c\u8bc1\uff0c\u4f7f\u7528\u4ee5\u4e0b\u5185\u5bb9\u521b\u5efa\u5e93\u5b58\u6587\u4ef6multi_pass_host\u3002<\/p>\n<pre class=\"post-pre\"><code>multi_pass_host[1:3]\r\n<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u4f7f\u7528playbook\u521b\u5efa\u540d\u4e3amulti_pass_host_site.yml\u7684\u6587\u4ef6\uff0c\u5e76\u6309\u7167\u4ee5\u4e0b\u5185\u5bb9\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"pi\">-<\/span> <span class=\"na\">hosts<\/span><span class=\"pi\">:<\/span> <span class=\"s\">all<\/span>\r\n  <span class=\"na\">gather_facts<\/span><span class=\"pi\">:<\/span> <span class=\"s\">no<\/span>\r\n  <span class=\"na\">tasks<\/span><span class=\"pi\">:<\/span>\r\n    <span class=\"pi\">-<\/span> <span class=\"na\">debug<\/span><span class=\"pi\">:<\/span>\r\n        <span class=\"na\">var<\/span><span class=\"pi\">:<\/span> <span class=\"s\">key1<\/span>\r\n<\/code><\/pre>\n<p>\u7528\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u4e2d\u5199\u597d\u7684\u5bc6\u7801\uff0c\u521b\u5efa\u4e00\u4e2a\u989d\u5916\u7684\u6587\u4ef6host_vars\/multi_pass_host3.yml\u5e76\u5bf9\u5176\u8fdb\u884c\u52a0\u5bc6\u3002<\/p>\n<pre class=\"post-pre\"><code>$ echo -n 'key1: value1c' | ansible-vault encrypt --vault-id label3@vault_multi_pass2 --output host_vars\/multi_pass_host3.yml\r\n<\/code><\/pre>\n<p>\u8981\u5728ANSIBLE_VAULT_ID_MATCH=False\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u6b64playbook\uff0c\u53ea\u9700\u4f7f\u7528&#8211;vault-id\u9009\u9879\u4e24\u6b21\u6307\u5b9a\uff0c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ansible-playbook -i multi_pass_host --vault-id vault_multi_pass1 --vault-id vault_multi_pass2 multi_pass_host_site.yml\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u5c06&#8211;vault-id\u9009\u9879\u6216\u8005\u4e24\u8005\u4e4b\u4e00\u66ff\u6362\u4e3a&#8211;vault-password-file\u9009\u9879\u6765\u6267\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ansible-playbook -i multi_pass_host --vault-password-file vault_multi_pass1 --vault-id vault_multi_pass2 multi_pass_host_site.yml\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>$ ansible-playbook -i multi_pass_host --vault-password-file vault_multi_pass1 --vault-password-file vault_multi_pass2 multi_pass_host_site.yml\r\n<\/code><\/pre>\n<p>\u5982\u679c ANSIBLE_VAULT_ID_MATCH=True \u7684\u8bdd\uff0c\u73b0\u5728\uff0c<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">host_vars\/multi_pass_host1.yml\u306f\u30e9\u30d9\u30eb\u306a\u3057<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">host_vars\/multi_pass_host2.yml\u306f\u30e9\u30d9\u30eb\u304clabel2<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">host_vars\/multi_pass_host3.yml\u306f\u30e9\u30d9\u30eb\u304clabel3<\/ul>\n<p>\u56e0\u6b64\uff0c\u8981\u6267\u884cplaybook\uff0c\u9700\u8981\u4f7f\u7528&#8211;vault-id\u9009\u9879\u4e09\u6b21\uff0c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ANSIBLE_VAULT_ID_MATCH=True ansible-playbook -i multi_pass_host --vault-id vault_multi_pass1 --vault-id label2@vault_multi_pass1 --vault-id label3@vault_multi_pass2 multi_pass_host_site.yml\r\n<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u672a\u6307\u5b9a\u6807\u7b7e\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528&#8211;vault-password-file\u9009\u9879\u66ff\u4ee3&#8211;vault-id\u9009\u9879\u6765\u6267\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ANSIBLE_VAULT_ID_MATCH=True ansible-playbook -i multi_pass_host --vault-password-file vault_multi_pass1 --vault-id label2@vault_multi_pass1 --vault-id label3@vault_multi_pass2 multi_pass_host_site.yml\r\n<\/code><\/pre>\n<p>\u5982\u679chost_vars\/multi_pass_host3.yml\u7684\u6807\u7b7e\u4e5f\u662flabel2\u7684\u8bdd\uff0c\u4e3a\u4e86\u6267\u884cplaybook\uff0c\u5982\u679cANSIBLE_VAULT_ID_MATCH=False\uff0c\u5219\u6807\u7b7e\u5c06\u88ab\u5ffd\u7565\uff0c\u56e0\u6b64\u7ed3\u679c\u4e0e\u539f\u6765\u4e00\u6837\uff1b\u4f46\u5982\u679cANSIBLE_VAULT_ID_MATCH=True\uff0c\u5219\u7ed3\u679c\u5982\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ANSIBLE_VAULT_ID_MATCH=True ansible-playbook -i multi_pass_host --vault-id vault_multi_pass1 --vault-id label2@vault_multi_pass1 --vault-id label2@vault_multi_pass2 multi_pass_host_site.yml\r\n<\/code><\/pre>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0c\u4e0d\u662f\u6bcf\u4e2a\u6807\u7b7e\u53ea\u80fd\u8bbe\u7f6e\u4e00\u4e2a\u5bc6\u7801\uff0c\u5373\u4f7f\u6807\u7b7e\u76f8\u540c\uff0c\u4e5f\u53ef\u4ee5\u7528\u591a\u4e2a\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\u3002\u6700\u7ec8\u89e3\u5bc6\u53ea\u4f1a\u5bf9\u5e94\u4e0e\u6307\u5b9a&#8211;vault-id\u9009\u9879\u4e2d\u7684\u6807\u7b7e\u548c\u5bc6\u7801\u76f8\u5339\u914d\u7684\u9879\u8fdb\u884c\u3002\u56e0\u6b64\uff0c\u6bcf\u4e2a\u9700\u8981\u89e3\u5bc6\u7684\u6807\u7b7e\u548c\u5bc6\u7801\u7ec4\u5408\u90fd\u9700\u8981\u6307\u5b9a&#8211;vault-id\u9009\u9879\u7684\u6b21\u6570\u3002<\/p>\n<h2>\u8981\u5b9e\u73b0\u7c7b\u4f3c\u4e8e\u4f7f\u7528ask-vault-pass\u9009\u9879\u7684\u529f\u80fd<\/h2>\n<p>\u7b2c\u4e09\u4e2a\u9009\u9879\u662f\uff0c\u5728\u89e3\u5bc6\u65f6\u4f7f\u7528ansible-vault decrypt\u3001ansible-vault view\u6216ansible-playbook\u7b49\u547d\u4ee4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528prompt\u4f5c\u4e3a&#8211;vault-id\u7684\u4ee3\u66ff\u9009\u9879\u6765\u6307\u5b9a\u5bc6\u7801\u6587\u4ef6\uff0c\u5e76\u5728\u6267\u884c\u65f6\u8981\u6c42\u8f93\u5165\u5bc6\u7801\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u4e0e&#8211;ask-vault-pass\u9009\u9879\u5177\u6709\u76f8\u540c\u7684\u6548\u679c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ANSIBLE_VAULT_ID_MATCH=True ansible-playbook -i multi_pass_host --vault-id prompt --vault-id label2@prompt --vault-id label2@prompt multi_pass_host_site.yml\r\n<\/code><\/pre>\n<p>\u5f53\u6267\u884c\u6b64\u64cd\u4f5c\u65f6\uff0c\u4f1a\u8981\u6c42\u8f93\u5165\u5bc6\u78013\u6b21\uff0c\u8f93\u5165\u6b63\u786e\u540e\u5373\u53ef\u6267\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code>Vault password (default):\r\nVault password (label2):\r\nVault password (label2):\r\n<\/code><\/pre>\n<h2>\u5728\u8a2d\u5b9a\u6a94\u7b49\u4e2d\u6307\u5b9a\u5305\u542b\u5bc6\u78bc\u7684\u6a94\u6848<\/h2>\n<p>\u6709\u5173\u8bbe\u7f6e\u7684\u6587\u6863\u53ef\u4ee5\u5728 https:\/\/docs.ansible.com\/ansible\/2.4\/config.html \u627e\u5230\u3002<\/p>\n<p>\u4f20\u7edf\u4e0a\uff0cansible.cfg\u6587\u4ef6\u4e2d\u7684[defaults]\u90e8\u5206\u7684vault_password_file\u7684\u503c\uff0c\u6216\u8005\u73af\u5883\u53d8\u91cfANSIBLE_VAULT_PASSWORD_FILE\u7684\u503c\u4ecd\u7136\u7b49\u540c\u4e8e&#8211;vault-password-file\u9009\u9879\uff0c\u4e5f\u5c31\u662f\u8bf4\u53ea\u80fd\u6307\u5b9a\u4e00\u4e2a\u6ca1\u6709\u6807\u7b7e\u7684\u5bc6\u7801\u6587\u4ef6\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u8bbe\u7f6eansible.cfg\u914d\u7f6e\u6587\u4ef6\u4e2d[defaults]\u90e8\u5206\u7684vault_identity_list\u503c\uff0c\u6216\u8005\u8bbe\u7f6e\u73af\u5883\u53d8\u91cfANSIBLE_VAULT_IDENTITY_LIST\u7684\u503c\uff0c\u8fd9\u4e9b\u503c\u90fd\u76f8\u5f53\u4e8e&#8211;vault-id\u9009\u9879\u7684\u503c\u3002<br \/>\n\u5982\u679c\u8981\u6307\u5b9a\u591a\u4e2a\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u9017\u53f7\u8fdb\u884c\u5206\u9694\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u6307\u5b9avault_multi_pass1\uff0clabel2@vault_multi_pass1\uff0clabel2@vault_multi_pass2\u3002<br \/>\n\u8fd8\u53ef\u4ee5\u4f7f\u7528\u503cprompt\uff0c\u5728\u4f7f\u7528\u65f6\u4f1a\u63d0\u793a\u8f93\u5165\u5bc6\u7801\u3002<\/p>\n<h1>\u8fd9\u4e2a\u80fd\u505a\u5230\uff0c\u4ec0\u4e48\u8ba9\u4f60\u9ad8\u5174\uff1f<\/h1>\n<p>\u5766\u767d\u8bf4\uff0c\u5982\u679c\u53ea\u770b\u8fd9\u4e2a\uff0c\u8981\u8bf4\u6709\u4ec0\u4e48\u8ba9\u4eba\u5f00\u5fc3\u7684\u4e8b\u60c5\uff0c\u6211\u5e76\u6ca1\u6709\u7279\u522b\u60f3\u5230\u7684\u3002<\/p>\n<p>\u56e0\u4e3a\u5f53\u9700\u8981\u67d0\u4e2a\u503c\u65f6\uff0c\u5982\u679c\u8be5\u503c\u88ab\u52a0\u5bc6\uff0c\u4f46\u6ca1\u6709\u63d0\u4f9b\u89e3\u5bc6\u5bc6\u7801\uff0c\u5219\u5f53\u524d\u4f1a\u8f93\u51fa\u201cERROR\uff01\u89e3\u5bc6\u5931\u8d25\uff08\u672a\u627e\u5230\u53ef\u4ee5\u89e3\u5bc6\u7684\u5bc6\u94a5\uff09\u201d\uff0c\u5e76\u4e14\u4efb\u52a1\u5c06\u5728\u6b64\u65f6\u7ec8\u6b62\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0c\u5982\u679c\u53ea\u662f\u4fee\u6539\u4e4b\u524d\u7684playbook\u6267\u884c\u547d\u4ee4\u7684\u6807\u7b7e\uff0c\u90a3\u4e48\u5c31\u65e0\u6cd5\u89e3\u5bc6\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ANSIBLE_VAULT_ID_MATCH=True ansible-playbook -i multi_pass_host --vault-id vault_multi_pass1 --vault-id label2@vault_multi_pass1 --vault-id label4@vault_multi_pass2 multi_pass_host_site.yml\r\n<\/code><\/pre>\n<p>\u6267\u884c\u7ed3\u679c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>PLAY [all] *******************************************************************************\r\nTASK [debug var=key1] ********************************************************************\r\nERROR! Decryption failed (no vault secrets would found that could decrypt) on (\u7701\u7565)\/host_vars\/multi_pass_host3.yml\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5728\u8fd9\u91cc\u4e0d\u51fa\u73b0\u9519\u8bef\u800c\u662f\u8df3\u8fc7\u9700\u8981\u8be5\u53d8\u91cf\u7684\u4efb\u52a1\uff0c\u6839\u636e\u6743\u9650\u7684\u4e0d\u540c\uff0c\u5373\u4f7f\u4f7f\u7528\u76f8\u540c\u7684playbook\u6267\u884c\u4e5f\u4f1a\u6709\u4e0d\u540c\u7684\u4efb\u52a1\u88ab\u6267\u884c\uff0c\u8fd9\u5c06\u5177\u6709\u4e00\u5b9a\u7684\u7528\u5904\u3002<\/p>\n<p>\u7531\u4e8e\u57282.5\u7248\u672c\u7684\u8def\u7ebf\u56fe\u4e2d\u63d0\u5230\uff1a\u201c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4e0d\u540c\u7684\u7528\u6237\u53ef\u80fd\u5e0c\u671b\u4ee5\u4e0d\u540c\u7684\u8bbf\u95ee\u7ea7\u522b\u4f7f\u7528\u76f8\u540c\u7684\u64ad\u653e\u529f\u80fd\uff0c\u80fd\u591f\u5c06\u89e3\u5bc6\u5931\u8d25\u7684\u4fdd\u9669\u5e93\u66f4\u6539\u4e3a\u8b66\u544a\u6216\u5176\u4ed6\u5185\u5bb9\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u201d\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u671f\u5f85\u8fd9\u4e00\u529f\u80fd\u7684\u5b9e\u73b0\u3002\uff08\u4f46\u662f\uff0c\u5373\u4f7f\u5728\u8def\u7ebf\u56fe\u4e2d\u63d0\u5230\uff0c\u5ef6\u671f\u4e5f\u662f\u5e38\u6709\u7684\u60c5\u51b5\uff09<\/p>\n<p>\u6211\u89c9\u5f97\u5982\u679c\u9664\u4e86\u53ef\u4ee5\u7528\u76f8\u540c\u7684\u5bc6\u94a5\u8fdb\u884c\u52a0\u5bc6\u4e4b\u5916\uff0c\u8fd8\u80fd\u591f\u4f7f\u7528\u4e0d\u540c\u7684\u6807\u7b7e\u6216\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\u5e76\u5f97\u5230\u4e0d\u540c\u7684\u503c\uff0c\u90a3\u5c31\u4f1a\u5f88\u6709\u8da3\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0c\u5982\u679c\u6211\u4eec\u5c06host_vars\/multi_pass_host3.yml\u7684\u5185\u5bb9\u6e05\u7a7a\uff0c\u7136\u540e\u4f7f\u7528Single Encrypted Variable\uff0c\u5728label1\u4e2d\u4f7f\u7528vault_multi_pass1\u5bf9&#8221;key1: value1d&#8221;\u8fdb\u884c\u52a0\u5bc6\uff0c\u5728label2\u4e2d\u4f7f\u7528vault_multi_pass2\u5bf9&#8221;key1: value1e&#8221;\u8fdb\u884c\u52a0\u5bc6\uff0c\u5219\u60c5\u51b5\u5982\u4e0b\uff1a<\/p>\n<pre class=\"post-pre\"><code>$ ansible-vault encrypt_string --vault-id label1@vault_multi_pass1 --name key1 value1d &gt; host_vars\/multi_pass_host3.yml\r\n$ ansible-vault encrypt_string --vault-id label2@vault_multi_pass2 --name key1 value1e &gt;&gt; host_vars\/multi_pass_host3.yml\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528vault_multi_pass1\u8fdb\u884c\u89e3\u5bc6\uff0ckey1\u7684\u503c\u5e94\u4e3avalue1d\uff1b\u5982\u679c\u4f7f\u7528vault_multi_pass2\u8fdb\u884c\u89e3\u5bc6\uff0ckey1\u7684\u503c\u5e94\u4e3avalue1e\u3002\u4f46\u5b9e\u9645\u4e0a\uff0c\u53ea\u6709\u540e\u4e00\u4e2a\u5177\u6709\u6709\u6548\u7684\u76f8\u540c\u952e\uff08\u53ef\u4ee5\u770b\u5230\u8b66\u544a\u6d88\u606f\uff1a\u201cline 1, column 1, found a duplicate dict key (key1). Using last defined value only.\u201d\uff09\u3002<\/p>\n<p>\u4f5c\u4e3a\u5bf9\u6b64\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u53ef\u4ee5\u5c06key1\u548ckey2\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\uff0c\u7136\u540e\u5728playbook\u4e2d\u5199\u5165`{{ key1 | default(key2) }}`\u3002\u4f46\u662f\uff0c\u6b63\u5982\u4e0a\u8ff0\u6240\u8ff0\uff0c\u5982\u679c\u65e0\u6cd5\u89e3\u5bc6key1\uff0c\u5219\u4f1a\u7acb\u5373\u53d1\u751f\u9519\u8bef\u5e76\u7ec8\u6b62\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4f1a\u7b49\u5f85\u672a\u6765\u7684\u7248\u672c\u3002<br \/>\n\u5f53\u7136\uff0c\u5373\u4f7f\u6211\u73b0\u5728\u53ef\u4ee5\u901a\u8fc7\u4e24\u4e2a\u4eba\u5206\u522b\u6536\u5230\u7684\u52a0\u5bc6\u6587\u4ef6\u6765\u6267\u884c\u64cd\u4f5c\uff0c\u8fd9\u5bf9\u6211\u6765\u8bf4\u53ef\u80fd\u4f1a\u6709\u4e00\u5b9a\u7684\u5e2e\u52a9\uff0c\u4f46\u8fd9\u79cd\u60c5\u51b5\u53ef\u80fd\u5e76\u4e0d\u592a\u5e38\u89c1\u3002<\/p>\n<hr \/>\n<div>\n<p>\u4f46\u662f\u6211\u5bf9\u4f20\u7edf\u7684\u65b9\u6cd5\u53ea\u611f\u89c9\u5230\u5b83\u53ef\u80fd\u4f1a\u88ab\u5f03\u7528\u3002<\/p>\n<p>\u5c31\u50cfansible-vault rekey\u547d\u4ee4\u91cd\u65b0\u8bbe\u7f6e\u52a0\u5bc6\u5bc6\u7801\u4e00\u6837\uff0c\u9664\u4e86\u4ece\u7ecf\u5178\u7684&#8211;vault-password-file\u9009\u9879\u5916\uff0c\u8fd8\u6dfb\u52a0\u4e86\u4e00\u4e2a\u65b0\u7684&#8211;new-vault-password-file\u9009\u9879\uff0c\u7528\u4e8e\u6307\u5b9a\u65b0\u7684\u5bc6\u7801\u6587\u4ef6\u3002<\/p>\n<p>\u5373\u4f7f\u5728\u53ea\u652f\u6301\u5230Ansible 2.3\u7684\u683c\u5f0f1.1\u7248\u672c\u4e2d\uff0c\u4f3c\u4e4e\u4e5f\u53ef\u4ee5\u8bfb\u53d61.2\u7248\u672c\u7684\u683c\u5f0f\u3002\u2192https:\/\/github.com\/ansible\/ansible\/pull\/22756<\/p>\n<p>\u5c3d\u7ba1\u5b98\u65b9\u6587\u6863\u4e2d\u5199\u7740\u5373\u4f7f\u4e3aFalse\u4e5f\u4f1a\u5c1d\u8bd5\u5148\u5339\u914did\uff0c\u7136\u540e\u6309\u987a\u5e8f\u5c1d\u8bd5\u5176\u4ed6\u7684vault ids\u3002\u4ece\u5f53\u524d\u884c\u4e3a\u6765\u770b\uff0c\u8fd9\u4e2a\u63cf\u8ff0\u4f3c\u4e4e\u6ca1\u6709\u610f\u4e49\uff08\u56e0\u4e3a\u53ea\u8981\u6709\u4e00\u4e2a\u53d8\u91cf\u65e0\u6cd5\u89e3\u5bc6\u5c31\u4f1a\u62a5\u9519\uff09\uff0c\u4f46\u672a\u6765\u53ef\u80fd\u4f1a\u6709\u6240\u6539\u53d8\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u4eceAnsible 2.4\u7248\u672c\u5f00\u59cb\uff0c\u901a\u8fc7Ansible Vault\uff0c\u5373\u4f7f\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u7801A\u548c\u5bc6\u7801B\u5bf9\u6587\u4ef6\u8fdb\u884c [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-42865","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-\u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u4eceAnsible 2.4\u7248\u672c\u5f00\u59cb\uff0c\u901a\u8fc7Ansible Vault\uff0c\u5373\u4f7f\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u7801A\u548c\u5bc6\u7801B\u5bf9\u6587\u4ef6\u8fdb\u884c [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-\u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-13T01:57:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-30T07:03:08+00:00\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/\",\"name\":\"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-01-13T01:57:50+00:00\",\"dateModified\":\"2024-04-30T07:03:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-\u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801","og_description":"\u9996\u5148 \u4eceAnsible 2.4\u7248\u672c\u5f00\u59cb\uff0c\u901a\u8fc7Ansible Vault\uff0c\u5373\u4f7f\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u7801A\u548c\u5bc6\u7801B\u5bf9\u6587\u4ef6\u8fdb\u884c [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-\u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-01-13T01:57:50+00:00","article_modified_time":"2024-04-30T07:03:08+00:00","author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/","name":"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-01-13T01:57:50+00:00","dateModified":"2024-04-30T07:03:08+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Ansible Vault \u73b0\u5728\u53ef\u4ee5\u89e3\u5bc6\u591a\u4e2a\u5bc6\u7801"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/ansible-vault-%e7%8e%b0%e5%9c%a8%e5%8f%af%e4%bb%a5%e8%a7%a3%e5%af%86%e5%a4%9a%e4%b8%aa%e5%af%86%e7%a0%81%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/42865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=42865"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/42865\/revisions"}],"predecessor-version":[{"id":92618,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/42865\/revisions\/92618"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=42865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=42865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=42865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}