Commit 844abc17 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

fix(ansible): 使用完整模块名并修复本地连接配置

parent 3e41c4a1
Loading
Loading
Loading
Loading
+28 −22
Original line number Original line Diff line number Diff line
@@ -43,6 +43,8 @@ endif
ifneq ($(strip $(HARBOR_REGISTRY)),)
ifneq ($(strip $(HARBOR_REGISTRY)),)
ANSIBLE_EXTRA_VARS += -e harbor_registry=$(HARBOR_REGISTRY)
ANSIBLE_EXTRA_VARS += -e harbor_registry=$(HARBOR_REGISTRY)
endif
endif
ANSIBLE_COLLECTIONS_DIR := $(CURDIR)/.ansible/collections
ANSIBLE_ENV = ANSIBLE_COLLECTIONS_PATH="$(ANSIBLE_COLLECTIONS_DIR)"


API_GATEWAY_BUILD_ARGS := --build-arg PIP_DEFAULT_TIMEOUT=$(PIP_DEFAULT_TIMEOUT) --build-arg PIP_RETRIES=$(PIP_RETRIES)
API_GATEWAY_BUILD_ARGS := --build-arg PIP_DEFAULT_TIMEOUT=$(PIP_DEFAULT_TIMEOUT) --build-arg PIP_RETRIES=$(PIP_RETRIES)
WORKER_STATS_AGENT_BUILD_ARGS := --build-arg PIP_DEFAULT_TIMEOUT=$(PIP_DEFAULT_TIMEOUT) --build-arg PIP_RETRIES=$(PIP_RETRIES)
WORKER_STATS_AGENT_BUILD_ARGS := --build-arg PIP_DEFAULT_TIMEOUT=$(PIP_DEFAULT_TIMEOUT) --build-arg PIP_RETRIES=$(PIP_RETRIES)
@@ -213,64 +215,68 @@ viewer-test-down:
update-code:
update-code:
	git pull
	git pull


ansible-deploy:
ansible-collections:
	@mkdir -p "$(ANSIBLE_COLLECTIONS_DIR)"
	@ansible-galaxy collection install -r ansible/requirements.yml -p "$(CURDIR)/.ansible" >/dev/null

ansible-deploy: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-deploy ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-deploy ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/deploy.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/deploy.yml $(ANSIBLE_EXTRA_VARS)


ansible-bootstrap:
ansible-bootstrap: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-bootstrap ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-bootstrap ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/bootstrap.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/bootstrap.yml $(ANSIBLE_EXTRA_VARS)


ansible-update:
ansible-update: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-update ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-update ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	echo "ENV=$(ENV)"; \
	echo "ENV=$(ENV)"; \
	echo "BUILD_NUMBER=$(BUILD_NUMBER)"; \
	echo "BUILD_NUMBER=$(BUILD_NUMBER)"; \
	echo "HARBOR_IMAGE_PREFIX=$(HARBOR_IMAGE_PREFIX)"; \
	echo "HARBOR_IMAGE_PREFIX=$(HARBOR_IMAGE_PREFIX)"; \
	echo "HARBOR_REGISTRY=$(HARBOR_REGISTRY)"
	echo "HARBOR_REGISTRY=$(HARBOR_REGISTRY)"
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/update.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/update.yml $(ANSIBLE_EXTRA_VARS)


ansible-update-master:
ansible-update-master: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-update-master ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-update-master ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/update.yml $(ANSIBLE_EXTRA_VARS) --tags master_update
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/update.yml $(ANSIBLE_EXTRA_VARS) --tags master_update


ansible-update-worker:
ansible-update-worker: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-update-worker ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-update-worker ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/update.yml $(ANSIBLE_EXTRA_VARS) --tags worker_update,post_worker_update
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/update.yml $(ANSIBLE_EXTRA_VARS) --tags worker_update,post_worker_update


ansible-down:
ansible-down: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-down ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-down ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/down.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/down.yml $(ANSIBLE_EXTRA_VARS)


ansible-stop:
ansible-stop: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-stop ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-stop ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/stop.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/stop.yml $(ANSIBLE_EXTRA_VARS)


ansible-start:
ansible-start: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-start ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-start ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/start.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/start.yml $(ANSIBLE_EXTRA_VARS)


ansible-kill:
ansible-kill: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-kill ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-kill ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/kill.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/kill.yml $(ANSIBLE_EXTRA_VARS)


ansible-check:
ansible-check: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-check ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-check ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/check.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/check.yml $(ANSIBLE_EXTRA_VARS)


ansible-sync-dags:
ansible-sync-dags: ansible-collections
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-sync-dags ENV=p368"; exit 1; fi
	@if [ -z "$(ENV)" ]; then echo "Error: ENV is not set. Usage: make ansible-sync-dags ENV=p368"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	@if [ ! -f "deploy_configs/$(ENV)/inventory.ini" ]; then echo "Error: deploy_configs/$(ENV)/inventory.ini not found"; exit 1; fi
	ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/sync_dags.yml $(ANSIBLE_EXTRA_VARS)
	$(ANSIBLE_ENV) ansible-playbook -i deploy_configs/$(ENV)/inventory.ini ansible/sync_dags.yml $(ANSIBLE_EXTRA_VARS)


pull:
pull:
	@total=$$(grep -v '^#' $(REQ_FILE) | grep -v '^$$' | wc -l); \
	@total=$$(grep -v '^#' $(REQ_FILE) | grep -v '^$$' | wc -l); \
+2 −2
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@
        mode: '0755'
        mode: '0755'


    - name: Synchronize project files to remote nodes
    - name: Synchronize project files to remote nodes
      synchronize:
      ansible.posix.synchronize:
        src: "{{ playbook_dir }}/../"
        src: "{{ playbook_dir }}/../"
        dest: "{{ _deploy_dir }}/"
        dest: "{{ _deploy_dir }}/"
        delete: no
        delete: no
@@ -58,7 +58,7 @@




    - name: Synchronize DAGs folder with deletion (avoid stale DAG variants)
    - name: Synchronize DAGs folder with deletion (avoid stale DAG variants)
      synchronize:
      ansible.posix.synchronize:
        src: "{{ playbook_dir }}/../dags/"
        src: "{{ playbook_dir }}/../dags/"
        dest: "{{ _deploy_dir }}/dags/"
        dest: "{{ _deploy_dir }}/dags/"
        delete: yes
        delete: yes
+3 −0
Original line number Original line Diff line number Diff line
---
collections:
  - name: ansible.posix
+1 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
        mode: '0755'
        mode: '0755'


    - name: Synchronize local DAGs folder to all nodes
    - name: Synchronize local DAGs folder to all nodes
      synchronize:
      ansible.posix.synchronize:
        src: "{{ local_project_dir }}/dags/"
        src: "{{ local_project_dir }}/dags/"
        dest: "{{ deploy_dir }}/dags/"
        dest: "{{ deploy_dir }}/dags/"
        delete: yes  # Removes remote DAGs that don't exist locally
        delete: yes  # Removes remote DAGs that don't exist locally
+2 −2
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@


    - name: Synchronize updated project files to remote nodes
    - name: Synchronize updated project files to remote nodes
      throttle: 1
      throttle: 1
      synchronize:
      ansible.posix.synchronize:
        src: "{{ playbook_dir }}/../"
        src: "{{ playbook_dir }}/../"
        dest: "{{ _deploy_dir }}/"
        dest: "{{ _deploy_dir }}/"
        delete: no
        delete: no
@@ -53,7 +53,7 @@


    - name: Synchronize DAGs folder with deletion (avoid stale DAG variants)
    - name: Synchronize DAGs folder with deletion (avoid stale DAG variants)
      throttle: 1
      throttle: 1
      synchronize:
      ansible.posix.synchronize:
        src: "{{ playbook_dir }}/../dags/"
        src: "{{ playbook_dir }}/../dags/"
        dest: "{{ _deploy_dir }}/dags/"
        dest: "{{ _deploy_dir }}/dags/"
        delete: yes
        delete: yes
Loading