라벨이 ansible인 게시물 표시

change password with ansible

ansible을 이용하여 agent 서버의 유저 패스워드 변경 1. 환경준비     Centos 7.x     Ansible  2. env ansible [root@localhost ~]# vi /etc/ansible/hosts # This is the default ansible 'hosts' file. # # It should live in /etc/ansible/hosts # #   - Comments begin with the '#' character #   - Blank lines are ignored #   - Groups of hosts are delimited by [header] elements #   - You can enter hostnames or ip addresses #   - A hostname/ip can be a member of multiple groups [testgroup] #192.168.0.156 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxxx 192.168.0.194 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxxx # edit playbook [root@localhost ~]# vi changepw.yml - hosts: testgroup   tasks:   - name: Test echo     shell:       whoami       echo -e 'oldpassword1\nlinuxpassword2\nlinuxpassword2' | passwd      register: cat   - debug: var=cat.stdout_lines      3. excute ansible [root@localhost ~]# ansible-playbook chan

ansible execute playbook

ansible을 이용한 playbook 실행  1. 환경준비     Centos 7.x 2. edit playbook [root@localhost ~]# vi /etc/ansible/hosts [testgroup] 192.168.0.156 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxx ansible_ssh_common_args='-o StrictHostKeyChecking=no' 192.168.0.116 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxx ansible_ssh_common_args='-o StrictHostKeyChecking=no' 192.168.0.177 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxx ansible_ssh_common_args='-o StrictHostKeyChecking=no' [root@localhost ~]# vi test.yml - hosts: testgroup   tasks:     - script: /usr/bin/date >> /tmp/date.log ~ ~ [root@localhost ~]# ansible-playbook test.yml PLAY [testgroup] ****************************************************************************************************************************** TASK [Gathering Facts] *************************************************************************************

ansible connect test(with ssh)

ansible을 이용하여 서버 접근 1. 환경준비     Centos 7.x     Ansible  2. env ansible [root@localhost ~]# vi /etc/ansible/hosts # This is the default ansible 'hosts' file. # # It should live in /etc/ansible/hosts # #   - Comments begin with the '#' character #   - Blank lines are ignored #   - Groups of hosts are delimited by [header] elements #   - You can enter hostnames or ip addresses #   - A hostname/ip can be a member of multiple groups [testgroup] 192.168.0.156 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxxx 192.168.0.116 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxxx 3. ping test [root@localhost ansible]# ansible testgroup -m ping 192.168.0.156 | FAILED! => {     "msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."

install redhat ansible with awx

ansible을 이용하여 서버 automation. 1. 환경준비     Centos 7.x 2. install ansible [root@localhost ~]#  yum -y install epel-release Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile  * base: mirror.kakao.com  * epel: mirrors.aliyun.com  * extras: mirror.kakao.com  * updates: mirror.kakao.com Package epel-release-7-11.noarch already installed and latest version Nothing to do [root@localhost ~]# yum -y install git gettext ansible docker nodejs npm gcc-c++ bzip2 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile  * base: mirror.kakao.com  * epel: mirrors.aliyun.com  * extras: mirror.kakao.com  * updates: mirror.kakao.com Package gettext-0.19.8.1-2.el7.x86_64 already installed and latest version Package 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 already installed and latest version Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transacti