Raspberry-Pi
解決執行 ansible yml 文件的錯誤
我正在嘗試在我的樹莓派上安裝一個叫做Internet-Pi的東西。我已按照說明進行操作,並且我相信一切都已正確安裝。我和我應該執行 ansible-playbook 的最後一步。
我得到錯誤:
pi@raspberrypi:~/internet-pi $ ansible-playbook main.yml ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path. The error appears to have been in '/home/pi/internet-pi/main.yml': line 26, column 7, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: handlers: - name: Include handlers. ^ here
我不知道從哪裡開始解決這個問題。yml 文件是:
--- - hosts: internet_pi become: true pre_tasks: - name: Load configuration (with defaults from example file). ansible.builtin.include_vars: "{{ item }}" loop: - example.config.yml - config.yml - name: Ensure apt cache is up to date. ansible.builtin.apt: update_cache: true cache_valid_time: 3600 when: - ansible_facts.os_family == "Debian" - name: Ensure pacman cache is up to date community.general.pacman: update_cache: true when: - ansible_facts.os_family == "Archlinux" handlers: - name: Include handlers. ansible.builtin.import_tasks: tasks/handlers.yml tasks: - name: Setup Docker. ansible.builtin.import_tasks: tasks/docker.yml - name: Set up Internet Monitoring. ansible.builtin.import_tasks: tasks/internet-monitoring.yml when: monitoring_enable - name: Set up Pi Hole. ansible.builtin.import_tasks: tasks/pi-hole.yml when: pihole_enable - name: Set up Shelly Plug Monitoring. ansible.builtin.import_tasks: tasks/shelly-plug.yml when: shelly_plug_enable - name: Set up Air Gradient Monitoring. ansible.builtin.import_tasks: tasks/airgradient.yml when: airgradient_enable - name: Set up Starlink Monitoring. ansible.builtin.import_tasks: tasks/starlink.yml when: starlink_enable
和 handlers.yml 是
--- - name: Restart pi-hole community.docker.docker_compose: project_src: ~/pi-hole/ build: false restarted: true become: false - name: Restart internet-monitoring community.docker.docker_compose: project_src: ~/internet-monitoring/ build: false restarted: true become: false - name: Restart shelly-plug-prometheus community.docker.docker_compose: project_src: ~/shelly-plug-prometheus/ build: false restarted: true become: false - name: Restart airgradient-prometheus community.docker.docker_compose: project_src: ~/airgradient-prometheus/ build: false restarted: true become: false - name: Restart starlink-exporter community.docker.docker_compose: project_src: ~/starlink-exporter/ build: false restarted: true become: false
如果我嘗試執行,
ansible.builtin.import_tasks
我會得到“找不到命令”。我應該從哪裡開始故障排除?
我在新的 Raspberry Pi 4 上設置 internet-pi 時遇到了同樣的問題,所以我決定
sudo apt purge ansible
從頭sudo apt purge python3-pip
開始。當這樣做時,我意識到我在第一次執行pip3 install ansible
後錯誤地執行sudo apt-get install -y python3-pip
了,當時 python3-pip 安裝就足夠了。所以我認為隨後的 ansible 顯式安裝以某種方式搞砸了 ansible 安裝。因此,在清除並安裝 python3-pip 之後,一切正常。