CentOS 6 상자 세트에서 printers.conf를 관리하려고 시도하는 다음과 같은 Unable playbook 파일이 있습니다. 컵 서비스의 정지를 제어하는 조건부 when
에서 "locst.stat.md5 북동 remst.stat.md5 : 조건 평가하면서 hostxxx] => 오류 치명적"어떻게 안전하게 printers.conf를 관리 할 수 있습니까?
---
# file: roles/common/tasks/config-cups.yml
# Configure printing
- name: ensure cups is installed
yum: pkg=cups state=installed
# We want to compare the local and remote printers.conf files so that
# we can predetermine if the copy needs to happen. According to a
# comment in the default printers.conf file, we can't write
# printers.conf while cups is running. But to be idempotent, we want
# to avoid stopping the cups service if we don't need to.
- stat: path=printers.conf
register: locst
- stat: path=/etc/cups/printers.conf
register: remst
# can't write printers.conf while running, so says the default file
- name: ensure cups is stopped
service: name=cups state=stopped
when: locst.stat.md5 ne remst.stat.md5
- name: Configure printers
tags: configuration
copy: >
src=printers.conf
dest=/etc/cups/printers.conf
mode=600 owner=root group=lp
notify:
- restart cups
- name: Enable the cups service
service: name=cups enabled=yes
- name: Ensure cups is running
service: name=cups state=started
불행히도 I 오류를 수신한다.
조건부 값을 평가하는 방법이 있습니까? -vvv
을 추가하면 여기에 도움이되지 않습니다.
조건부 디버깅 방법이 있습니까?
EDIT1 :
은 분명히 통계 모듈이 항상 원격 -이 역할의 로컬 printers.conf에 대해 일치하지/일반/파일/printers.conf
TASK: [common | stat path=printers.conf] **************************************
<hostxxx> ESTABLISH CONNECTION FOR USER[...]
<hostxxx> REMOTE_MODULE stat path=printers.conf
[...]
ok: [hostxxx] => {"changed": false, "stat": {"exists": false}}
이 될 것이다 조건부를 평가하는 동안 내 "오류"의 출처.
그래서 나는 파일을 깨끗하게 관리하는 방법을 모른다. 나는 작업에 md5 값을 코딩하는 것을 손에 넣고 싶지 않습니다.
이 stackoverflow question은 거의 동일한 것을 찾습니다.
EDIT2 : 지금 local_action
를 사용하여 로컬 파일에 대해 실행 통계 모듈을 얻을 수있어 더 긴 경로 해결 방법 위해 lack of role-path searching in local actions 만 평가하는 동안
, 나는 여전히 같은 오류가 조건부. 올바른 .stat.md5 값을 갖고 있음에도 불구하고.
- local_action: stat path=roles/common/files/printers.conf
register: locst
그러나 나는 md5 값이 예기치 않게 다릅니다. 런타임 중에 컵이 "StateTime"이라는 타임 스탬프라는 것을 비롯하여 printers.conf 파일을 다시 쓰는 것으로 보입니다. config 파일을 작성하여 컵을 관리하는 간단한 방법입니다.
AFAICT는 컵을 깔끔하게 관리 할 수있는 유일한 방법으로, 매번 서비스가 중단 될 때마다 비교하기 전에 기존 printers.conf를 필터링하거나 훨씬 덜 합리적인 방식으로 웹 스캐너를 작성하여 작동하도록합니다. 인터페이스 컵은 프린터 구성에 사용하기를 원합니다.
- name: Configure printers
tags: configuration
copy: src=printers.conf dest=/etc/cups/printers.conf mode=600 owner=root group=lp validate="service cups stop %s"
- name: Ensure cups is running
service: name=cups state=started
을 % s는 서비스에 대한 불필요 (: ansible 가정
는
"stat path = printers.conf"가 로컬 파일과 일치하지 않는 경우 이전에 -vvv 출력에 오류의 원인을 찾았습니다. –