본문 바로가기

퍼블릭 클라우드

[Ansible] lineinfile 모듈

반응형

Ansible lineinfile 모듈

lineinfile 모듈

- 호스트 파일 편집(/etc/ansible/hosts)

$ ansible dbs -m lineinfile -b -K -a "dest=/etc/hosts line='10.31.3.72 galera01' state=present"
BECOME password:
db1 | CHANGED => {
    "backup": "",
    "changed": true,
    "msg": "line added"
}
db3 | CHANGED => {
    "backup": "",
    "changed": true,
    "msg": "line added"
}
db2 | CHANGED => {
    "backup": "",
    "changed": true,
    "msg": "line added"
}


$ ansible dbs -m lineinfile -b -K -a "dest=/etc/hosts line='10.31.3.72 galera01\n10.31.4.78 galera02\n10.31.3.63 galera03' state=present"
BECOME password:
db3 | CHANGED => {
    "backup": "",
    "changed": true,
    "msg": "line added"
}
db2 | CHANGED => {
    "backup": "",
    "changed": true,
    "msg": "line added"
}
db1 | CHANGED => {
    "backup": "",
    "changed": true,
    "msg": "line added"
}
728x90
반응형