# add host to your ssh known_hosts
ssh server-name-01
#
# note the setup:
# 1. Playbook.yml, 2. -i (inventory), 3. pass common vars, including password vault, 4. pass extra vars, including hostname and environment, 5. unlock the password vault
#
ansible-playbook configure-apt.yml -i "server-name-01," -e @common_vars/common_vars.yml --extra-vars 'env=local variable_host=server-name-01' -v -C --vault-password-file ~/vars/.common.txt

 

 
---
- name: Test Playbook to run a shell command
hosts: "{{ variable_host | default('host-group-name')}}"
become: yes
tasks:
- name: run this command and ignore the result
  shell: /usr/bin/somecommand
  ignore_errors: True
...

Pass the host list as a variable:

hosts: "{{ variable_host | default('web')}}"
 
# command
ansible-playbook server.yml --extra-vars "variable_host=server-name-01"

'나는 노동자 > LINUX' 카테고리의 다른 글

rpm으로 패키지 설치 유무 확인  (0) 2023.05.09
ansible 물리서버, 가성서버 확인  (0) 2023.02.07
ansible facts device check  (0) 2023.02.04
리눅스 임시 포트 오픈  (0) 2023.01.12
xfs volume extend  (0) 2020.07.10

+ Recent posts