본문 바로가기
Ansible

ansible 구축/실행 명령어 모음

by 도경다경 2022. 3. 31.
반응형

[Ansible 설치]

yum install -y perl             ## vmware-tools 설치할 때 필요해서 넣어둠

yum install -y epel-release   ## CentOS ansible은 epel 에 있음
yum install -y ansible         ## Ansible 설치
yum install -y python3        ## 요즘 python은 3버전 쓴대서 추가
yum install python-pip -y    ## python 기반 install은 pip
pip install ansible-cmdb      ## ansible-cmdb는 pip 로 설치
yum install python-mako -y ## ansible-cmdb 실행시 mako 요구
yum install nginx -y           ## ansible-cmdb web으로 뿌려주기 위해 설치
pip install pywinrm            ## windows 관리를 위해 설치

[Ansible-cmdb 사용]
mkdir out                       ## ansible setup 모듈로 가져올 구성정보 저장 위치
ansible -m setup --tree out/ all   ## ansible로 구성정보 가져오기
ansible-cmdb out/ >   /usr/share/nginx/html/index.html 

## 가져온 구성정보 기반 웹 페이지 생성, 가급적 웹으로 바로 볼 수 있게 nginx homedir로 다이렉트 설정

 

[Ansible 스터디하면서 실행한 명령어]

ansible all -m user -a "name=osr" -k
ansible all -m shell -a "tail -n 1 /etc/passwd" -k
ansible all -m user -a "name=osr state=absent" -k
ansible all -m yum -a "name=httpd state=present" -k
curl httpd.apache.org -o index.html
ansible all -m copy -a "src=index.html > dest=/var/www/html/index.html" -k
ansible all -m service -a "name=httpd state=started" -k
ansible all -m shell -a "systemctl stop firewalld" -k

echo "nameserver 192.168.63.1" >> /etc/resolv.conf
echo "nameserver 192.168.63.2" >> /etc/resolv.conf

ansible localhost -c local -m lineinfile -a > "path=customized_inven.lst line=192.168.1.14"

ansible-playbook nginx_install.yml -k

반응형

'Ansible' 카테고리의 다른 글

Ansible playbook test  (0) 2023.02.01
Ansible 설치 및 ping test  (0) 2023.02.01
Ansible ssh-keygen 귀찮을 때  (0) 2022.05.23
ping 모듈 테스트 시 에러  (0) 2022.04.11
nginx_install.yml  (0) 2022.03.31

댓글