Re: [ansible-project] how to read a yaml file and update itself ?

2021-11-11 Thread Eric Chang
'center_id': item.center_id, > > 'center_password': lookup('pipe', 'pwgen -sy 48 1') > > } > > > ]) }} > > > loop: "{{ lookup('file', filename)|from_yaml|json_query('centers[]') > }}" > > > - copy: >

Re: [ansible-project] how to read a yaml file and update itself ?

2021-11-07 Thread Eric Chang
>> Is this file local or on your remote host? local dick@geant.org 在 2021年11月5日 星期五下午3:04:57 [UTC+8] 的信中寫道: > Is this file local or on your remote host? > > On Fri, 5 Nov 2021 at 02:13, Eric Chang wrote: > >> let's said I have a yaml file like >>

[ansible-project] how to read a yaml file and update itself ?

2021-11-04 Thread Eric Chang
let's said I have a yaml file like centers.yml centers: - center_id: ABC123 center_password: 123456789 - center_id: 123ABC center_password: "" now I want to read the centers.yml , and update center_password with pwgen(8) if center_password is null and write back to centers.yml How

[ansible-project] how to get values from dict in template with for loop ?

2021-07-19 Thread Eric Chang
I have two dict file like teams.yml { "teams": [{"gid": 10125,"location": ["hq"],"name": "aa","users": ["chenhu","chouf"]}, {"gid": 10126,"location": ["hq"],"name": "ac","users": ["guoj","yangc"]} ] } users.yml { "users": [{"name": "changc","uid": 2},

Re: [ansible-project] how to dynamic update value in vars_file

2020-05-14 Thread Eric Chang
so , what module you recommend ? Stefan Hornburg (Racke)於 2020年5月13日星期三 UTC+8下午10時12分58秒寫道: > > On 5/13/20 3:58 PM, Eric Chang wrote: > > location is defined in inventory file , but I have trouble to update > nodes.pub > > > > lineinfile is not appropriate for any

Re: [ansible-project] how to dynamic update value in vars_file

2020-05-13 Thread Eric Chang
efan Hornburg (Racke)於 2020年5月13日星期三 UTC+8下午4時03分16秒寫道: > > On 5/13/20 9:32 AM, Eric Chang wrote: > > like I said , I want to update nodes.ma <http://nodes.ma> with > somevalue based on location in playbook , if ma is not > > defined. > > ma is matai

Re: [ansible-project] how to dynamic update value in vars_file

2020-05-13 Thread Eric Chang
ike doing things backwards. > Could you tell more about your ACTUAL deployment goal(s)? I.e. what > are you trying to achieve with ansible? > > On Wed, 13 May 2020 at 03:34, Eric Chang > > wrote: > > > > I have a var file like > > > > nodes: >

[ansible-project] how to dynamic update value in vars_file

2020-05-12 Thread Eric Chang
I have a var file like nodes: - name: rk12 location: tp-101 ma: own: - name: rk14 location: tp-201 ma: p11023 own: p11023 - name: rk15 location: tc-332 ma: own: p92032 and I want to update nodes.ma with somevalue based on location in playbook , if

[ansible-project] not able to run playbook in ansible 2.9.2

2020-02-18 Thread Eric Chang
I wrote a simple plabook to test ansible_play_name --- > - hosts: localhost > > tasks: > - name: ref playname > debug: > msg: ansible_play_name > I can run the playbook in ansible 2.8 , but get an error in ansible 2.9.2 ansible 2.8.0 > > (.28) 2020-02-19 11:40:35

[ansible-project] Re: include_vars in folders

2020-02-15 Thread Eric Chang
so any suggesions to combine multiple yaml files with same attributes ? -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to

[ansible-project] include_vars in folders

2020-02-14 Thread Eric Chang
according to https://docs.ansible.com/ansible/2.5/modules/include_vars_module.html this task should load all yaml files in /home/yaml/users and assign to var 'users' - name: load yaml using include_vars with dir > include_vars: > name: 'users' > dir: /home/yaml/users/ >

Re: [ansible-project] dynamic load yaml using include_vars and use these vars later

2020-02-14 Thread Eric Chang
thanks ! it's working now ! Stefan Hornburg (Racke)於 2020年2月14日星期五 UTC+8下午6時08分30秒寫道: > > >Try "{{ vars[item]['name'] }}". Only variables inside the double curly > braces are evaluated. > > >Regards > > Racke > > > > > -- > > You received this message because you are subscribed to

[ansible-project] dynamic load yaml using include_vars and use these vars later

2020-02-13 Thread Eric Chang
I have dozens of yaml files , and I want to use these yaml files as vars in playbook. so I try to dynamic load vars like aaa.yaml , bbb.yaml,ccc.yaml - name: get all yaml files name shell: find /home/yaml -name *.yamlawk -F "/" '{print $6}'|awk -F "." '{print $1}' register: yaml_files

[ansible-project] how to get specified order of strings in list ?

2020-02-09 Thread Eric Chang
I have a list like this user: name: chchang comment: "Chang Chic Hung" and I want to add more attrs like last_name: Chang mid_name: Chic but how to get the specifed order of the values ? I try to use filter "first" , but it just return "C" , the first letter , not the first word. any

[ansible-project] unable to install vim plugin via shell module

2020-01-15 Thread Eric Chang
I want to install vim plugins with ansible shell module the task is quite simple as follow - name: install vim vundle plugin > shell: "vim +PluginInstall +qall" > but the playbook will hang at this task like forever. even with -vv or -vvv , there`s no more detail log , it just hangs ! any

[ansible-project] problem to fetch value from var files

2019-06-27 Thread Eric Chang
I have a yml file named: client_hosts.yml it looks like below client_hosts: > abc.com: > - host: dc021 > ipv4: 192.168.11.21 > - host: dc022 > ipv4: 192.168.11.22 > - host: dc023 > ipv4: 192.168.11.23 > iuser: True > user: john > - host: dc024 > ipv4:

[ansible-project] Re: how to get value from yaml file ?

2018-11-22 Thread Eric Chang
> > > tags: > - env > include_vars: > file: files/teams.yml > name: teams > > - name: debug > tags: > - env > debug: > msg: "{{ ite

[ansible-project] newbie - do something when database is not there ?

2018-09-14 Thread Eric Chang
I have a task , want to do something when a specified database is not in postgresql using command "psql --list" - name: check if db exists tags: ¦ - checkdbexists ¦ - test command: "psql --list" register: dbexists - name: debug dbexist tags: ¦- test ¦- debug

[ansible-project] Re: newbie seeks for help about register

2018-09-12 Thread Eric Chang
> > > thanks for reply > what if I want to use value in here "item": { "dhome": "/home/ccw/D", "name": "ccw", "nb": "dc078.abc.com", "neohome": "/home/ccw/D/eus", "ws": "qs054.abc.com" I try

[ansible-project] how to get a complete git log using ansible to do git pull

2018-08-06 Thread Eric Chang
I wrote a easy playbook to been called when devops do a git push with webhook. if Devs do a git push , webhook will notify my ansible server to run a script which run anisble-playbook myplaybook -i inventory_name -vvv | tee -a /tmp/myplaybook_result.log but the log file only contain the