ansible

[筆記] 為了保存log 用script 指令執行ansible / Another Way to Keep Ansible Log using script command

之前為了能夠在執行完 ansible playbook 後,能有個log 可以看

所以在每次執行的時候,都要加入 tee 的指令

像是

ANSIBLE_CONFIG=/home/D/ansiblecontrol/ansible.cfg /usr/local/bin/ansible-playbook  /home/D/ansiblecontrol/playbook.user_client.yml --vault-password-file=/home/D/ansiblecontrol/vault.passwd -i /home/D/ansiblecontrol/inventory/production -f1 --limit tyuserclients |tee /tmp/tyuserclients.log

一直都是放在crontab 裡面執行,也就沒有去管他

反正也沒有人關心結果怎樣 (攤手

[筆記] Ansible how to use 'list' in yaml file

這幾天在玩ansible 時,碰到一個問題

假如我有個yaml檔作為資料來源,檔名是 abc.yml

大概長這樣

    "teams": [
        {
            "chinese_name": "TEAM1",
            "description": "TEAM1",
            "gid": 10125,
            "location": [
                "hq"
            ],
            "name": "aa",
            "users": [
                "chen",
                "chou",
                "huani",
                "yey",
                "wa"
            ]
        },
        {
            "chinese_name": "TEAM2",
            "description": "TEAM2",
            "gid": 10126,
            "location": [
                "hq"
            ],
            "name": "bb",
            "users": [
                "chhiao",
                "chgc",
                "chy",
                "hsi",
                "li",
                "li",
                "chgchi"
            ]
        }
		]