Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

請問如何更新 var file 裡面的某個值? #51

Open
changchichung opened this issue May 12, 2020 · 2 comments
Open

請問如何更新 var file 裡面的某個值? #51

changchichung opened this issue May 12, 2020 · 2 comments

Comments

@changchichung
Copy link

var file 大概長這樣

nodes:
  - name: aaa
    location: somewhere
    pub: 
    pri:
  - name: bbb
    location: someotherplace
    pub: pubpub
    pri: pripri
  - name: ccc
    location: someotherplace
    pub: 
    pri: pripri

我想在playbook 中,先include 這個var file
然後檢查 pub/pri 的值,如果pub/pri 沒有定義,依照location不同,塞不同的字串給它
我一開始先用lineinfile ,可是我不知道怎麼指定取代pub沒有定義的位置
用regexp 的話,有可能會有兩行符合條件,例如上面的aaa.pub , ccc.pub
在regexp 裡面都是一樣的,都會被取代
那有沒有辦法可以指定取代 aaa.pub 這個欄位呢?

@chusiang
Copy link
Member

我看了 3 遍,還是不太了解想解決什麼問題,以及上面在做什麼?

還請補上更詳細的說明。

@changchichung
Copy link
Author

就是,我有一個 yaml 檔案,我要怎麼在ansible 中引用這個檔案,當這裡面的某個欄位值是空的,就依照規則去更新這個空值

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants