|
20 | 20 | - name: Only do this if bacalhau isnt installed or upgrade is needed
|
21 | 21 | when: bacalhau_installed_version is undefined or bacalhau_installed_version != bacalhau_version
|
22 | 22 | block:
|
23 |
| - - name: Fetch AWS EC2 Metadata facts |
24 |
| - amazon.aws.ec2_metadata_facts: |
25 |
| - |
26 |
| - - name: Print environment info |
27 |
| - ansible.builtin.debug: |
28 |
| - msg: "Running on environment: {{ ansible_ec2_tags_instance_Env }}" |
29 |
| - when: ansible_ec2_tags_instance_Env is defined |
30 |
| - |
31 |
| - - name: Set fact when its prod node |
32 |
| - ansible.builtin.set_fact: |
33 |
| - requester_hostname: "requester.labdao.xyz" |
34 |
| - ipfs_hostname: "ipfs.labdao.xyz" |
35 |
| - when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower == "prod" |
36 |
| - |
37 |
| - - name: Set fact when its non-prod node |
38 |
| - ansible.builtin.set_fact: |
39 |
| - requester_hostname: "requester.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz" |
40 |
| - ipfs_hostname: "ipfs.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz" |
41 |
| - when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower != "prod" |
42 |
| - |
43 |
| - # Bacalhau PeerID, example `curl -s bacalhau.staging.labdao.xyz:1234/node_info | jq -r '.PeerInfo.ID'` |
44 |
| - - name: Determine requester bacalhau peer id |
45 |
| - ansible.builtin.uri: |
46 |
| - url: "http://{{ requester_hostname }}:1234/node_info" |
47 |
| - return_content: true |
48 |
| - register: requester_output |
49 |
| - when: requester_hostname is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*") |
50 |
| - |
51 |
| - - name: Set requester_peer url |
52 |
| - ansible.builtin.set_fact: |
53 |
| - # requester_peer: /dns4/requester.staging.labdao.xyz/tcp/1235/p2p/QmeLa2fx2FMNDWbeY3UqjELc1MbKwNxggcmdBmLZepY6VK |
54 |
| - requester_peer: "/dns4/{{ requester_hostname }}/tcp/1235/p2p/{{ requester_output.content | from_json | community.general.json_query('PeerInfo.ID') }}" |
55 |
| - when: requester_output is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*") |
56 |
| - |
57 |
| - - name: Set ipfs connect url |
58 |
| - ansible.builtin.set_fact: |
59 |
| - ipfs_connect: "/dns4/{{ ipfs_hostname }}/tcp/5001" |
60 |
| - when: ipfs_hostname is defined |
61 |
| - |
62 | 23 | - name: Download Bacalhau binary
|
63 | 24 | become: true
|
64 | 25 | ansible.builtin.unarchive:
|
|
72 | 33 | delay: 3
|
73 | 34 | until: bacalhau_unarchive is succeeded
|
74 | 35 |
|
75 |
| - - name: Install the Bacalhau systemd unit |
76 |
| - become: true |
77 |
| - ansible.builtin.template: |
78 |
| - src: "files/{{ bacalhau_node_type }}.service" |
79 |
| - dest: /etc/systemd/system |
80 |
| - notify: |
81 |
| - - Restart Bacalhau |
| 36 | +- name: Fetch AWS EC2 Metadata facts |
| 37 | + amazon.aws.ec2_metadata_facts: |
82 | 38 |
|
83 |
| - - name: Ensure Bacalhau is running |
84 |
| - become: true |
85 |
| - ansible.builtin.service: |
86 |
| - name: "{{ bacalhau_node_type }}" |
87 |
| - state: started |
88 |
| - enabled: true |
| 39 | +- name: Print environment info |
| 40 | + ansible.builtin.debug: |
| 41 | + msg: "Running on environment: {{ ansible_ec2_tags_instance_Env }}" |
| 42 | + when: ansible_ec2_tags_instance_Env is defined |
| 43 | + |
| 44 | +- name: Set fact when its prod node |
| 45 | + ansible.builtin.set_fact: |
| 46 | + requester_hostname: "requester.labdao.xyz" |
| 47 | + ipfs_hostname: "ipfs.labdao.xyz" |
| 48 | + when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower == "prod" |
| 49 | + |
| 50 | +- name: Set fact when its non-prod node |
| 51 | + ansible.builtin.set_fact: |
| 52 | + requester_hostname: "requester.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz" |
| 53 | + ipfs_hostname: "ipfs.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz" |
| 54 | + when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower != "prod" |
| 55 | + |
| 56 | +# Bacalhau PeerID, example `curl -s bacalhau.staging.labdao.xyz:1234/node_info | jq -r '.PeerInfo.ID'` |
| 57 | +- name: Determine requester bacalhau peer id |
| 58 | + ansible.builtin.uri: |
| 59 | + url: "http://{{ requester_hostname }}:1234/node_info" |
| 60 | + return_content: true |
| 61 | + register: requester_output |
| 62 | + when: requester_hostname is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*") |
| 63 | + |
| 64 | +- name: Set requester_peer url |
| 65 | + ansible.builtin.set_fact: |
| 66 | + # requester_peer: /dns4/requester.staging.labdao.xyz/tcp/1235/p2p/QmeLa2fx2FMNDWbeY3UqjELc1MbKwNxggcmdBmLZepY6VK |
| 67 | + requester_peer: "/dns4/{{ requester_hostname }}/tcp/1235/p2p/{{ requester_output.content | from_json | community.general.json_query('PeerInfo.ID') }}" |
| 68 | + when: requester_output is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*") |
| 69 | + |
| 70 | +- name: Set ipfs connect url |
| 71 | + ansible.builtin.set_fact: |
| 72 | + ipfs_connect: "/dns4/{{ ipfs_hostname }}/tcp/5001" |
| 73 | + when: ipfs_hostname is defined |
| 74 | + |
| 75 | +- name: Install the Bacalhau systemd unit |
| 76 | + become: true |
| 77 | + ansible.builtin.template: |
| 78 | + src: "files/{{ bacalhau_node_type }}.service" |
| 79 | + dest: /etc/systemd/system |
| 80 | + notify: |
| 81 | + - Restart Bacalhau |
| 82 | + |
| 83 | +- name: Ensure Bacalhau is running |
| 84 | + become: true |
| 85 | + ansible.builtin.service: |
| 86 | + name: "{{ bacalhau_node_type }}" |
| 87 | + state: started |
| 88 | + enabled: true |
0 commit comments