disable proxy
This commit is contained in:
		
							
								
								
									
										312
									
								
								playbook.yaml
									
									
									
									
									
								
							
							
						
						
									
										312
									
								
								playbook.yaml
									
									
									
									
									
								
							@ -125,19 +125,19 @@
 | 
				
			|||||||
#      async: "{{ 60 * 20 }}"
 | 
					#      async: "{{ 60 * 20 }}"
 | 
				
			||||||
#      poll: 30
 | 
					#      poll: 30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Check no-proxy ipfs access
 | 
					#    - name: Check no-proxy ipfs access
 | 
				
			||||||
      ansible.builtin.shell: |
 | 
					#      ansible.builtin.shell: |
 | 
				
			||||||
        curl -s -w "%{http_code}" -o response.json {{ ipfs_url }}
 | 
					#        curl -s -w "%{http_code}" -o response.json {{ ipfs_url }}
 | 
				
			||||||
      register: noproxy_check
 | 
					#      register: noproxy_check
 | 
				
			||||||
      changed_when: false
 | 
					#      changed_when: false
 | 
				
			||||||
      failed_when: noproxy_check.stdout != "200"
 | 
					#      failed_when: noproxy_check.stdout != "200"
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
    - name: Check proxy ipfs access
 | 
					#    - name: Check proxy ipfs access
 | 
				
			||||||
      ansible.builtin.shell: |
 | 
					#      ansible.builtin.shell: |
 | 
				
			||||||
        curl -s -w "%{http_code}" -o response.json -x {{ proxy }} {{ ipfs_url }}
 | 
					#        curl -s -w "%{http_code}" -o response.json -x {{ proxy }} {{ ipfs_url }}
 | 
				
			||||||
      register: proxy_check
 | 
					#      register: proxy_check
 | 
				
			||||||
      changed_when: false
 | 
					#      changed_when: false
 | 
				
			||||||
      failed_when: proxy_check.stdout != "200"
 | 
					#      failed_when: proxy_check.stdout != "200"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#    - name: Install Docker
 | 
					#    - name: Install Docker
 | 
				
			||||||
#      ansible.builtin.shell: curl -fsSL https://get.docker.com | bash
 | 
					#      ansible.builtin.shell: curl -fsSL https://get.docker.com | bash
 | 
				
			||||||
@ -219,132 +219,132 @@
 | 
				
			|||||||
      async: "{{ 60 * 45 }}"
 | 
					      async: "{{ 60 * 45 }}"
 | 
				
			||||||
      poll: "{{ 60 * 5 }}"
 | 
					      poll: "{{ 60 * 5 }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Docker pre-up
 | 
					#    - name: Docker pre-up
 | 
				
			||||||
      ansible.builtin.command: docker compose up -d
 | 
					#      ansible.builtin.command: docker compose up -d
 | 
				
			||||||
      args:
 | 
					#      args:
 | 
				
			||||||
        chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node"
 | 
					#        chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node"
 | 
				
			||||||
      environment:
 | 
					#      environment:
 | 
				
			||||||
        COMPOSE_INTERACTIVE_NO_CLI: 'true'
 | 
					#        COMPOSE_INTERACTIVE_NO_CLI: 'true'
 | 
				
			||||||
      changed_when: false
 | 
					#      changed_when: false
 | 
				
			||||||
      async: "{{ 60 * 80 }}"
 | 
					#      async: "{{ 60 * 80 }}"
 | 
				
			||||||
      poll: "{{ 60 * 5 }}"
 | 
					#      poll: "{{ 60 * 5 }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Check Docker container status
 | 
					#    - name: Check Docker container status
 | 
				
			||||||
      ansible.builtin.shell: >
 | 
					#      ansible.builtin.shell: >
 | 
				
			||||||
        if [ $(docker ps -q | wc -l) -eq $(docker ps -a -q | wc -l) ]; then
 | 
					#        if [ $(docker ps -q | wc -l) -eq $(docker ps -a -q | wc -l) ]; then
 | 
				
			||||||
          echo "all_running";
 | 
					#          echo "all_running";
 | 
				
			||||||
        else
 | 
					#        else
 | 
				
			||||||
          echo "not_all_running";
 | 
					#          echo "not_all_running";
 | 
				
			||||||
        fi
 | 
					#        fi
 | 
				
			||||||
      register: container_status
 | 
					#      register: container_status
 | 
				
			||||||
      retries: 10
 | 
					#      retries: 10
 | 
				
			||||||
      delay: 30
 | 
					#      delay: 30
 | 
				
			||||||
      until: container_status.stdout.find("all_running") != -1
 | 
					#      until: container_status.stdout.find("all_running") != -1
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Docker stop (pre-up)
 | 
				
			||||||
 | 
					#      ansible.builtin.command: docker compose stop
 | 
				
			||||||
 | 
					#      args:
 | 
				
			||||||
 | 
					#        chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node"
 | 
				
			||||||
 | 
					#      environment:
 | 
				
			||||||
 | 
					#        COMPOSE_INTERACTIVE_NO_CLI: 'true'
 | 
				
			||||||
 | 
					#      changed_when: false
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Check external IP before
 | 
				
			||||||
 | 
					#      ansible.builtin.command: curl https://ifconfig.me
 | 
				
			||||||
 | 
					#      register: ip_before
 | 
				
			||||||
 | 
					#      changed_when: false
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Validate IP address
 | 
				
			||||||
 | 
					#      ansible.builtin.assert:
 | 
				
			||||||
 | 
					#        that:
 | 
				
			||||||
 | 
					#          - ip_before.stdout | ansible.utils.ipaddr
 | 
				
			||||||
 | 
					#        fail_msg: "The returned value is not a valid IP address."
 | 
				
			||||||
 | 
					#        success_msg: "The returned value is a valid IP address."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Docker stop (pre-up)
 | 
					#    - name: Download tun2socks
 | 
				
			||||||
      ansible.builtin.command: docker compose stop
 | 
					#      ansible.builtin.get_url:
 | 
				
			||||||
      args:
 | 
					#        url: https://github.com/xjasonlyu/tun2socks/releases/download/v2.5.2/tun2socks-linux-amd64.zip
 | 
				
			||||||
        chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node"
 | 
					#        dest: /tmp/tun2socks-linux-amd64.zip
 | 
				
			||||||
      environment:
 | 
					#        mode: '0644'
 | 
				
			||||||
        COMPOSE_INTERACTIVE_NO_CLI: 'true'
 | 
					#      async: "{{ 60 * 5 }}"
 | 
				
			||||||
      changed_when: false
 | 
					#      poll: 30
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Unzip tun2socks
 | 
				
			||||||
 | 
					#      ansible.builtin.unarchive:
 | 
				
			||||||
 | 
					#        src: /tmp/tun2socks-linux-amd64.zip
 | 
				
			||||||
 | 
					#        dest: /usr/local/sbin/
 | 
				
			||||||
 | 
					#        remote_src: true
 | 
				
			||||||
 | 
					#        mode: '0755'
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Create proxy file
 | 
				
			||||||
 | 
					#      ansible.builtin.copy:
 | 
				
			||||||
 | 
					#        content: "{{ proxy }}"
 | 
				
			||||||
 | 
					#        dest: /root/proxy
 | 
				
			||||||
 | 
					#        mode: '0644'
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Create tun2socks systemd service
 | 
				
			||||||
 | 
					#      ansible.builtin.copy:
 | 
				
			||||||
 | 
					#        dest: /etc/systemd/system/tun2socks.service
 | 
				
			||||||
 | 
					#        content: |
 | 
				
			||||||
 | 
					#          [Unit]
 | 
				
			||||||
 | 
					#          Description=Tun2Socks gateway
 | 
				
			||||||
 | 
					#          After=network.target
 | 
				
			||||||
 | 
					#          Wants=network.target
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#          [Service]
 | 
				
			||||||
 | 
					#          User=root
 | 
				
			||||||
 | 
					#          Type=simple
 | 
				
			||||||
 | 
					#          RemainAfterExit=true
 | 
				
			||||||
 | 
					#          ExecStartPre=/bin/sh -c 'ip route add $(cat /root/proxy | grep -oP "(?<=@)[0-9.]+(?=:)" )/32 via $(ip route | grep -oP "(?<=default via )[0-9.]+")'
 | 
				
			||||||
 | 
					#          ExecStart=/bin/sh -c '/usr/local/sbin/tun2socks-linux-amd64 --device tun0 --proxy $(cat /root/proxy)'
 | 
				
			||||||
 | 
					#          ExecStopPost=/bin/sh -c 'ip route del $(cat /root/proxy | grep -oP "(?<=@)[0-9.]+(?=:)" )/32 via $(ip route | grep -oP "(?<=default via )[0-9.]+")'
 | 
				
			||||||
 | 
					#          Restart=always
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#          [Install]
 | 
				
			||||||
 | 
					#          WantedBy=multi-user.target
 | 
				
			||||||
 | 
					#        mode: '0644'
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Create network configuration for tun0
 | 
				
			||||||
 | 
					#      ansible.builtin.copy:
 | 
				
			||||||
 | 
					#        dest: /etc/systemd/network/10-proxy.network
 | 
				
			||||||
 | 
					#        content: |
 | 
				
			||||||
 | 
					#          [Match]
 | 
				
			||||||
 | 
					#          Name=tun0
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#          [Network]
 | 
				
			||||||
 | 
					#          Address=10.20.30.1/24
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#          [Route]
 | 
				
			||||||
 | 
					#          Gateway=0.0.0.0
 | 
				
			||||||
 | 
					#        mode: '0644'
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Enable and start tun2socks service
 | 
				
			||||||
 | 
					#      ansible.builtin.systemd:
 | 
				
			||||||
 | 
					#        name: tun2socks
 | 
				
			||||||
 | 
					#        enabled: true
 | 
				
			||||||
 | 
					#        state: started
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Reload network configuration
 | 
				
			||||||
 | 
					#      ansible.builtin.command: networkctl reload
 | 
				
			||||||
 | 
					#      changed_when: false
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#    - name: Restart tun2socks service
 | 
				
			||||||
 | 
					#      ansible.builtin.systemd:
 | 
				
			||||||
 | 
					#        name: tun2socks
 | 
				
			||||||
 | 
					#        state: restarted
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Check external IP before
 | 
					    - name: Check API availability for RPC URL
 | 
				
			||||||
      ansible.builtin.command: curl https://ifconfig.me
 | 
					      ansible.builtin.uri:
 | 
				
			||||||
      register: ip_before
 | 
					        url: "{{ rpc_url }}/health?"
 | 
				
			||||||
      changed_when: false
 | 
					        method: GET
 | 
				
			||||||
 | 
					        return_content: true
 | 
				
			||||||
    - name: Validate IP address
 | 
					        timeout: 30
 | 
				
			||||||
      ansible.builtin.assert:
 | 
					      register: rpc_url_response
 | 
				
			||||||
        that:
 | 
					      retries: 3
 | 
				
			||||||
          - ip_before.stdout | ansible.utils.ipaddr
 | 
					      delay: 120
 | 
				
			||||||
        fail_msg: "The returned value is not a valid IP address."
 | 
					      failed_when:
 | 
				
			||||||
        success_msg: "The returned value is a valid IP address."
 | 
					        - rpc_url_response.status != 200
 | 
				
			||||||
 | 
					        - rpc_url_response.json is not none and rpc_url_response.json is not defined
 | 
				
			||||||
    - name: Download tun2socks
 | 
					 | 
				
			||||||
      ansible.builtin.get_url:
 | 
					 | 
				
			||||||
        url: https://github.com/xjasonlyu/tun2socks/releases/download/v2.5.2/tun2socks-linux-amd64.zip
 | 
					 | 
				
			||||||
        dest: /tmp/tun2socks-linux-amd64.zip
 | 
					 | 
				
			||||||
        mode: '0644'
 | 
					 | 
				
			||||||
      async: "{{ 60 * 5 }}"
 | 
					 | 
				
			||||||
      poll: 30
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Unzip tun2socks
 | 
					 | 
				
			||||||
      ansible.builtin.unarchive:
 | 
					 | 
				
			||||||
        src: /tmp/tun2socks-linux-amd64.zip
 | 
					 | 
				
			||||||
        dest: /usr/local/sbin/
 | 
					 | 
				
			||||||
        remote_src: true
 | 
					 | 
				
			||||||
        mode: '0755'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Create proxy file
 | 
					 | 
				
			||||||
      ansible.builtin.copy:
 | 
					 | 
				
			||||||
        content: "{{ proxy }}"
 | 
					 | 
				
			||||||
        dest: /root/proxy
 | 
					 | 
				
			||||||
        mode: '0644'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Create tun2socks systemd service
 | 
					 | 
				
			||||||
      ansible.builtin.copy:
 | 
					 | 
				
			||||||
        dest: /etc/systemd/system/tun2socks.service
 | 
					 | 
				
			||||||
        content: |
 | 
					 | 
				
			||||||
          [Unit]
 | 
					 | 
				
			||||||
          Description=Tun2Socks gateway
 | 
					 | 
				
			||||||
          After=network.target
 | 
					 | 
				
			||||||
          Wants=network.target
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          [Service]
 | 
					 | 
				
			||||||
          User=root
 | 
					 | 
				
			||||||
          Type=simple
 | 
					 | 
				
			||||||
          RemainAfterExit=true
 | 
					 | 
				
			||||||
          ExecStartPre=/bin/sh -c 'ip route add $(cat /root/proxy | grep -oP "(?<=@)[0-9.]+(?=:)" )/32 via $(ip route | grep -oP "(?<=default via )[0-9.]+")'
 | 
					 | 
				
			||||||
          ExecStart=/bin/sh -c '/usr/local/sbin/tun2socks-linux-amd64 --device tun0 --proxy $(cat /root/proxy)'
 | 
					 | 
				
			||||||
          ExecStopPost=/bin/sh -c 'ip route del $(cat /root/proxy | grep -oP "(?<=@)[0-9.]+(?=:)" )/32 via $(ip route | grep -oP "(?<=default via )[0-9.]+")'
 | 
					 | 
				
			||||||
          Restart=always
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          [Install]
 | 
					 | 
				
			||||||
          WantedBy=multi-user.target
 | 
					 | 
				
			||||||
        mode: '0644'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Create network configuration for tun0
 | 
					 | 
				
			||||||
      ansible.builtin.copy:
 | 
					 | 
				
			||||||
        dest: /etc/systemd/network/10-proxy.network
 | 
					 | 
				
			||||||
        content: |
 | 
					 | 
				
			||||||
          [Match]
 | 
					 | 
				
			||||||
          Name=tun0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          [Network]
 | 
					 | 
				
			||||||
          Address=10.20.30.1/24
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          [Route]
 | 
					 | 
				
			||||||
          Gateway=0.0.0.0
 | 
					 | 
				
			||||||
        mode: '0644'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Enable and start tun2socks service
 | 
					 | 
				
			||||||
      ansible.builtin.systemd:
 | 
					 | 
				
			||||||
        name: tun2socks
 | 
					 | 
				
			||||||
        enabled: true
 | 
					 | 
				
			||||||
        state: started
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Reload network configuration
 | 
					 | 
				
			||||||
      ansible.builtin.command: networkctl reload
 | 
					 | 
				
			||||||
      changed_when: false
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Restart tun2socks service
 | 
					 | 
				
			||||||
      ansible.builtin.systemd:
 | 
					 | 
				
			||||||
        name: tun2socks
 | 
					 | 
				
			||||||
        state: restarted
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#    - name: Check API availability for RPC URL
 | 
					 | 
				
			||||||
#      ansible.builtin.uri:
 | 
					 | 
				
			||||||
#        url: "{{ rpc_url }}/health?"
 | 
					 | 
				
			||||||
#        method: GET
 | 
					 | 
				
			||||||
#        return_content: true
 | 
					 | 
				
			||||||
#        timeout: 30
 | 
					 | 
				
			||||||
#      register: rpc_url_response
 | 
					 | 
				
			||||||
#      retries: 3
 | 
					 | 
				
			||||||
#      delay: 120
 | 
					 | 
				
			||||||
#      failed_when:
 | 
					 | 
				
			||||||
#        - rpc_url_response.status != 200
 | 
					 | 
				
			||||||
#        - rpc_url_response.json is not none and rpc_url_response.json is not defined
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Check API availability for Binance URL
 | 
					    - name: Check API availability for Binance URL
 | 
				
			||||||
      ansible.builtin.uri:
 | 
					      ansible.builtin.uri:
 | 
				
			||||||
@ -375,26 +375,26 @@
 | 
				
			|||||||
      register: wallet_balance_check
 | 
					      register: wallet_balance_check
 | 
				
			||||||
      failed_when: wallet_balance_check.rc != 0
 | 
					      failed_when: wallet_balance_check.rc != 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Check external IP after
 | 
					#    - name: Check external IP after
 | 
				
			||||||
      ansible.builtin.command: curl https://ifconfig.me
 | 
					#      ansible.builtin.command: curl https://ifconfig.me
 | 
				
			||||||
      register: ip_after
 | 
					#      register: ip_after
 | 
				
			||||||
      changed_when: false
 | 
					#      changed_when: false
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
    - name: Validate IP address
 | 
					#    - name: Validate IP address
 | 
				
			||||||
      ansible.builtin.assert:
 | 
					#      ansible.builtin.assert:
 | 
				
			||||||
        that:
 | 
					#        that:
 | 
				
			||||||
          - ip_after.stdout | ansible.utils.ipaddr
 | 
					#          - ip_after.stdout | ansible.utils.ipaddr
 | 
				
			||||||
        fail_msg: "The returned value is not a valid IP address."
 | 
					#        fail_msg: "The returned value is not a valid IP address."
 | 
				
			||||||
        success_msg: "The returned value is a valid IP address."
 | 
					#        success_msg: "The returned value is a valid IP address."
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
    - name: Show IPs
 | 
					#    - name: Show IPs
 | 
				
			||||||
      ansible.builtin.debug:
 | 
					#      ansible.builtin.debug:
 | 
				
			||||||
        msg: "External IP before: {{ ip_before.stdout }}, External IP after: {{ ip_after.stdout }}"
 | 
					#        msg: "External IP before: {{ ip_before.stdout }}, External IP after: {{ ip_after.stdout }}"
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
    - name: Compare external IPs
 | 
					#    - name: Compare external IPs
 | 
				
			||||||
      ansible.builtin.fail:
 | 
					#      ansible.builtin.fail:
 | 
				
			||||||
        msg: "External IP before and after should not be the same"
 | 
					#        msg: "External IP before and after should not be the same"
 | 
				
			||||||
      when: ip_before.stdout == ip_after.stdout
 | 
					#      when: ip_before.stdout == ip_after.stdout
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Docker up
 | 
					    - name: Docker up
 | 
				
			||||||
      ansible.builtin.command: docker compose up -d
 | 
					      ansible.builtin.command: docker compose up -d
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user