update some content
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
"articleSection" : "post",
|
||||
"name" : "[筆記]在ansible中,取得loop register後的值\/ Ansible Get Value From Loop Register",
|
||||
"headline" : "[筆記]在ansible中,取得loop register後的值\/ Ansible Get Value From Loop Register",
|
||||
"description" : "\x3cp\x3e今天在寫一支客製化 firefox 的playbook\x3c\/p\x3e\n\x3cp\x3e因為firefox 會給每個user 建立一個由亂數字串組成的default profile\x3c\/p\x3e\n\x3cp\x3e所以每個user的 default profile 都不同\x3c\/p\x3e\n\x3cp\x3e也因此在用register處理的時候,碰到了一些問題\x3c\/p\x3e",
|
||||
"description" : "\u003cp\u003e今天在寫一支客製化 firefox 的playbook\u003c\/p\u003e\n\u003cp\u003e因為firefox 會給每個user 建立一個由亂數字串組成的default profile\u003c\/p\u003e\n\u003cp\u003e所以每個user的 default profile 都不同\u003c\/p\u003e\n\u003cp\u003e也因此在用register處理的時候,碰到了一些問題\u003c\/p\u003e",
|
||||
"inLanguage" : "en",
|
||||
"author" : "Eric Chang",
|
||||
"creator" : "Eric Chang",
|
||||
@@ -21,8 +21,8 @@
|
||||
"accountablePerson" : "Eric Chang",
|
||||
"copyrightHolder" : "Eric Chang",
|
||||
"copyrightYear" : "2019",
|
||||
"datePublished": "2019-12-27 09:09:05 \x2b0800 CST",
|
||||
"dateModified" : "2019-12-27 09:09:05 \x2b0800 CST",
|
||||
"datePublished": "2019-12-27 09:09:05 \u002b0800 CST",
|
||||
"dateModified" : "2019-12-27 09:09:05 \u002b0800 CST",
|
||||
"url" : "https:\/\/h.cowbay.org\/post\/ansible-get-value-from-loop-register\/",
|
||||
"wordCount" : "236",
|
||||
"image" : "https://h.cowbay.orghttps://h.cowbay.org/images/post-default-7.jpg"",
|
||||
@@ -45,9 +45,9 @@
|
||||
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
|
||||
|
||||
<link href="https://h.cowbay.org/css/style.css?v=1632901488" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
|
||||
<link href="https://h.cowbay.org/css/style.css?v=1634607506" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
|
||||
|
||||
<link href="https://h.cowbay.org/css/custom.css?v=1632901488" rel="stylesheet" type='text/css' media='all'>
|
||||
<link href="https://h.cowbay.org/css/custom.css?v=1634607506" rel="stylesheet" type='text/css' media='all'>
|
||||
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
||||
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
||||
|
||||
@@ -311,7 +311,7 @@ if (!doNotTrack) {
|
||||
<h3 id="task-內容">TASK 內容</h3>
|
||||
<p>其實task 內容沒有很複雜,簡單來說,就是先檢查user的 firefox profile 目錄</p>
|
||||
<p>如果存在就pass,如果不存在就幫user建立</p>
|
||||
<pre><code>- name: check if user profile exists
|
||||
<pre tabindex="0"><code>- name: check if user profile exists
|
||||
become_user: "{{ item.name }}"
|
||||
stat:
|
||||
path: "{{ firefox_home }}"
|
||||
@@ -323,7 +323,7 @@ if (!doNotTrack) {
|
||||
<p>所以可以肯定的是 stat 這個屬性一定在</p>
|
||||
<p>可是也一定有什麼問題,造成取不到值</p>
|
||||
<p>當然就是先debug 來看看(有些不重要的屬性,我就先拿掉了)</p>
|
||||
<pre><code>ok: [hqdc075] => {
|
||||
<pre tabindex="0"><code>ok: [hqdc075] => {
|
||||
"profile_exists": {
|
||||
"changed": false,
|
||||
"msg": "All items completed",
|
||||
@@ -391,7 +391,7 @@ if (!doNotTrack) {
|
||||
<h3 id="修正後續task">修正後續task</h3>
|
||||
<p>後面的task 稍微改一下,在指定 with_items 的時候,直接指定 profile_exists.results</p>
|
||||
<p>接下來的用法就比較簡單了,跟原本接stat 變數的語法差不多</p>
|
||||
<pre><code>- name: run firefox to create default profile
|
||||
<pre tabindex="0"><code>- name: run firefox to create default profile
|
||||
become_user: "{{ item.item.name }}"
|
||||
shell: "firefox --headless &"
|
||||
ignore_errors: True
|
||||
@@ -688,7 +688,7 @@ title="pinterest icon"></i>
|
||||
</div>
|
||||
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
|
||||
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
|
||||
<script src="https://h.cowbay.org/js/production.min.js?v=1632901488"></script>
|
||||
<script src="https://h.cowbay.org/js/production.min.js?v=1634607506"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user