ansible output 가공

호두·2026년 2월 22일

ansible로 명령어를 수행하면 아래와 같은 output이 나온다.

ansible -i hosts all -m shell -a "hostname -f" -u testuser -b -k
[DEPRECATION WARNING]: [defaults]collections_paths option, does not fit var naming standard, use the singular form collections_path instead. This feature will be removed from ansible-core in version 2.19. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
SSH password:
10.1.2.3 | CHANGED | rc=0 >>
test.server1.com
(...)
10.1.2.6 | CHANGED | rc=0 >>
test.server2.com

vim에서 아래와 같이 수행

:%s/ | CHANGED | rc=0 >>//g
:g/^/join

이 상태라면 column 별로 정렬이 안되어 있어 block 설정이 어려움
이때는 column 명령어를 통해 정렬

column -t list

이렇게 한 후에 sort 명령어를 통해 delimeter를 지정하고 정렬 기준을 설정한 후 sorting 하면 데이터 준비 끝

sort -t' ' -k2 list

profile
Whatever you're not changing, you're choosing

0개의 댓글