Skip to content

Commit 093e70d

Browse files
committed
583: access services in local network
Task-URL: #583
1 parent ffcbf1c commit 093e70d

File tree

12 files changed

+118
-35
lines changed

12 files changed

+118
-35
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/first_setup/
2+
/mylyn_vars/

org.eclipse.mylyn.releng/multipass/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,18 @@ This setup is only tested on am MacBook Pro M1.
8080
or
8181
ansible-playbook create_vm.yml --ask-become-pass --extra-vars="docker_run_mode=single"
8282
ansible-playbook mylyn_setup.yml --extra-vars="docker_run_mode=single"
83-
```
83+
```
84+
85+
Now you can use the URLs https://traefik.mylyn.local and https://mylyn.local/mylyn_idx/ for verification on the installation host computer.
86+
You will get certification warnings and must trust the self signed certificate.
87+
88+
If you want to access the URLs from an other computer in your local environment you must add a line to your /etc/hosts file.
89+
Look into /etc/hosts of your installation host computer and you see the following line
90+
```
91+
192.168.64.3 mylynmstr01 mylyn.local traefik.mylyn.local jenkins.mylyn.local hello.mylyn.local artifactory.mylyn.local gitlab.mylyn.local
92+
```
93+
copy this line and replace the IP adress with the local network IP address assinged to the mylynmstr01 vm
94+
```
95+
192.168.2.120 mylynmstr01 mylyn.local traefik.mylyn.local jenkins.mylyn.local hello.mylyn.local artifactory.mylyn.local gitlab.mylyn.local
96+
```
97+
Now you shold be able to assess the URLs from the other computer

org.eclipse.mylyn.releng/multipass/create_vm.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
#
44
- hosts: localhost
55
gather_facts: true
6+
pre_tasks:
7+
- file:
8+
path: mylyn_vars
9+
state: directory
10+
post_tasks:
11+
- no_log: false
12+
copy:
13+
force: true
14+
dest: "mylyn_vars/{{ inventory_hostname }}.json"
15+
content: "{{ vars | dict2items | json_query('[?starts_with(key, `inst_`)]') | items2dict }}"
616
tasks:
717
- name: include global mode
818
ansible.builtin.include_tasks:
@@ -13,6 +23,17 @@
1323
#
1424
- hosts: localhost
1525
gather_facts: false
26+
pre_tasks:
27+
- include_vars:
28+
dir: mylyn_vars
29+
extensions:
30+
- json
31+
post_tasks:
32+
- no_log: false
33+
delegate_to: localhost
34+
copy:
35+
dest: "mylyn_vars/{{ inventory_hostname }}.json"
36+
content: "{{ vars | dict2items | json_query('[?starts_with(key, `inst_`)]') | items2dict }}"
1637
roles:
1738
- role: multipass_create_vm
1839
tags:
@@ -26,6 +47,17 @@
2647
#
2748
- hosts: "{{ hostvars['localhost'].rootca_server_name }}"
2849
gather_facts: false
50+
pre_tasks:
51+
- include_vars:
52+
dir: mylyn_vars
53+
extensions:
54+
- json
55+
post_tasks:
56+
- no_log: false
57+
delegate_to: localhost
58+
copy:
59+
dest: "mylyn_vars/{{ inventory_hostname }}.json"
60+
content: "{{ vars | dict2items | json_query('[?starts_with(key, `inst_`)]') | items2dict }}"
2961
vars:
3062
rootca_name: "{{ hostvars['localhost'].rootca_server_name }}"
3163
roles:

org.eclipse.mylyn.releng/multipass/global_setup.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
remote_domain: "{{ remote_dom | default('public.mydomain.de')}}"
66
docker_swarm_recreate: "{{ swarm_recreate | default(false) }}"
77
docker_mode_global: "{{ docker_run_mode | default('container') }}"
8+
network_ip_matcher: "{{ local_network_ip_matcher | default('^192\\.168\\.2\\..*') }}"
89
tags:
910
- global
1011

@@ -59,16 +60,15 @@
5960
- "{{ setup_lst_tmp }}"
6061
tags:
6162
- global
62-
63-
- ansible.builtin.debug: msg="all hosts = {{ setup_lst }}" # verbosity=3
64-
tags:
65-
- global
66-
- ansible.builtin.debug: msg="all non admin vm = {{ setup_noadmin_vm_list }}" # verbosity=3
67-
tags:
68-
- global
69-
- ansible.builtin.debug: msg="rootca_server_name = {{ rootca_server_name }}" # verbosity=3
70-
tags:
71-
- global
72-
- ansible.builtin.debug: msg="prim_install_server_name = {{ prim_install_server_name }}" # verbosity=3
63+
- name: debug list
64+
vars:
65+
msg: |
66+
rootca_server_name = {{ rootca_server_name }}
67+
localhostPlatform = {{ localhostPlatform }}
68+
all hosts = {{ setup_lst }}
69+
all non admin vm = {{ setup_noadmin_vm_list }}
70+
ansible.builtin.debug:
71+
msg: "{{ msg.split('\n') }}"
72+
verbosity: 0
7373
tags:
74-
- global
74+
- global

org.eclipse.mylyn.releng/multipass/inventory.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ all:
1515
multipass_disk: 30G
1616
multipass_memory: 10G
1717
multipass_cpus: 4
18-
# additional_launch_parms: --network en0 # acces from external
18+
# only needed when you want to share your instance to other devices in Network or Internet
19+
additional_launch_parms: '--network=en0'
1920
mylyn_swarm_worker:
2021
hosts:
2122
mylynwrk01:
@@ -37,7 +38,7 @@ all:
3738
ansible_user: ubuntu
3839
ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o ControlMaster=no -o ControlPath=none"
3940
ansible_ssh_private_key_file: first_setup/ubuntu_key
40-
default_etc_hosts: "mylyn-local traefik.mylyn.local mylyn-local.mylyn.local mylyn.local jenkins.mylyn.local hello.mylyn.local artifactory.mylyn.local gitlab.mylyn.local"
41+
default_etc_hosts: "mylynmstr01 mylyn.local traefik.mylyn.local jenkins.mylyn.local hello.mylyn.local artifactory.mylyn.local gitlab.mylyn.local"
4142
mylynwrk01:
4243
ansible_connection: ssh
4344
ansible_host: "192.168.64.4"

org.eclipse.mylyn.releng/multipass/mylyn_setup.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
#
6666
- hosts: "{{ hostvars['localhost'].prim_install_server_name }}"
6767
gather_facts: false
68+
pre_tasks:
69+
- include_vars:
70+
dir: mylyn_vars
71+
extensions:
72+
- json
6873
vars:
6974
swarm_master_name: "{{ hostvars['localhost'].prim_install_server_name }}"
7075
docker_mode: "{{ hostvars['localhost'].docker_mode_global }}"

org.eclipse.mylyn.releng/multipass/roles/bugzilla/tasks/build_start.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
var: extra_info_label
5353
- name: myServiceLabel {{ act_item.image_tag }}
5454
set_fact:
55-
serviceLabel: '{"type":"{{ bugzilla_type }}","url":"/{{ act_item.servmame }}/", "version": "{{ bugzilla_version.stdout }}", "info": "{{ bugzilla_info }}", "properties": { "host-name": "{{ remote_domain_name }}", "host-ip": "{{ansible_ssh_host}}", "ansible-name": "{{ inventory_hostname }}", "docker": "true" {{ extra_info_label }} } }'
55+
serviceLabel: '{"type":"{{ bugzilla_type }}","url":"/{{ act_item.servmame }}/", "version": "{{ bugzilla_version.stdout }}", "info": "{{ bugzilla_info }}", "properties": { "host-name": "{{ remote_domain_name }}", "remote_ip": "{{ inst_network_ip }}", "ansible-name": "{{ inventory_hostname }}", "ansible-host-ip": "{{ansible_ssh_host}}", "docker": "true" {{ extra_info_label }} } }'
5656
- name: debug1 {{ act_item.image_tag }}
5757
debug:
5858
var: serviceLabel

org.eclipse.mylyn.releng/multipass/roles/gitlab/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
- name: myServiceLabel
3333
set_fact:
34-
serviceLabel: '{"type":"gitlab","url":"https://{{ gitlabHostURL }}","version":"{{gitlabImageVersion}}","info":"","properties":{"host-name":"{{ gitlabHostURL }}","host-ip":"{{ansible_ssh_host}}","ansible-name":"{{ inventory_hostname }}","docker":"true","default":"true"} }'
34+
serviceLabel: '{"type":"gitlab","url":"https://{{ gitlabHostURL }}","version":"{{gitlabImageVersion}}","info":"","properties":{"host-name":"{{ gitlabHostURL }}","remote_ip": "{{ inst_network_ip }}","ansible-host-ip":"{{ansible_ssh_host}}","ansible-name":"{{ inventory_hostname }}","docker":"true","default":"true"} }'
3535

3636
- name: setlabels registry
3737
ansible.builtin.set_fact:

org.eclipse.mylyn.releng/multipass/roles/jenkins/tasks/build_start.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
extra_info_label: "{{ (',' + act_item.extra_info) if (act_item.extra_info | length > 0 ) else ''}}"
4040
- name: myServiceLabel
4141
set_fact:
42-
serviceLabel: '{"type":"{{ jenkins_type }}","url":"/{{act_item.servmame}}/", "version": "{{version.stdout}}", "info": "", "properties": { "host-name": "{{ common_domain_name }}", "host-ip": "{{ansible_ssh_host}}", "ansible-name": "{{ inventory_hostname }}", "docker": "true" {{ extra_info_label }} } }'
42+
serviceLabel: '{"type":"{{ jenkins_type }}","url":"/{{act_item.servmame}}/", "version": "{{version.stdout}}", "info": "", "properties": { "host-name": "{{ remote_domain_name }}", "remote_ip": "{{ inst_network_ip }}", "ansible-host-ip": "{{ansible_ssh_host}}", "ansible-name": "{{ inventory_hostname }}", "docker": "true" {{ extra_info_label }} } }'
4343

4444
- name: setlabels {{ act_item.image_tag }}
4545
ansible.builtin.set_fact:

org.eclipse.mylyn.releng/multipass/roles/multipass_create_vm/tasks/main.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@
2828
- {{ user_data }}
2929
3030
- name: create if needed
31-
shell: multipass launch -n {{ item.name }} --disk {{ item.disk }} --mem {{ item.memory }} --cpus {{ item.cpus }} --cloud-init first_setup/cloud-init.yaml
31+
shell: multipass launch -n {{ item.name }} --disk {{ item.disk }} --mem {{ item.memory }} --cpus {{ item.cpus }} {{ item.launch_extra }} --cloud-init first_setup/cloud-init.yaml
3232
when: item.name not in inst_list | map(attribute='inst_name')
3333
with_items: "{{ setup_lst }}"
3434
- name: new list
3535
ansible.builtin.include_tasks:
3636
file: multipass_list.yml
37-
- debug: var=inst_list verbosity=3
37+
- name: debug new list
38+
debug: var=inst_list verbosity=3
3839

3940
- name: build name ip map
4041
ansible.builtin.set_fact:
@@ -43,7 +44,8 @@
4344
item.name in inst_list | map(attribute='inst_name') and
4445
(inst_list | selectattr("inst_name", "equalto", item.name))| map(attribute='ip_adr4') != [item.ip4 ]
4546
with_items: "{{ setup_lst }}"
46-
- debug: var=ip_2_change verbosity=3
47+
- name: debug ip_2_change
48+
debug: var=ip_2_change verbosity=3
4749
when: ip_2_change is defined
4850

4951
- name: "Replace line in file inventory.yml"
@@ -52,22 +54,24 @@
5254
regexp: "(^\\s*ansible_host:\\s*)(\"{{ item.aip | regex_escape() }}\")(.*)$"
5355
replace: "\\1\"{{item.mip}}\""
5456
with_items: "{{ ip_2_change }}"
55-
when: ip_2_change is defined
56-
- name: change etc hosts
57+
when: ip_2_change is defined
58+
59+
- name: remove mylyn vm from etc hosts
5760
become: true
5861
become_user: root
59-
ansible.builtin.replace:
62+
ansible.builtin.lineinfile:
6063
path: /etc/hosts
61-
regexp: "{{item.aip | regex_escape()}}(\\s+.*)?$"
62-
replace: "{{item.mip}}\\1"
64+
regexp: "{{'^.*'+ item.aname +'.*' }}"
65+
state: absent
6366
with_items: "{{ ip_2_change }}"
64-
when: ip_2_change is defined and (not item.aip is search("192.168.64.x"))
65-
- name: append etc hosts
67+
when: ip_2_change is defined
68+
69+
- name: add mylyn vm to etc hosts}
6670
become: true
6771
become_user: root
6872
ansible.builtin.lineinfile:
6973
path: /etc/hosts
70-
line: "{{ item.mip }} {{hostvars[item.aname].default_etc_hosts}}"
71-
insertafter: EOF
74+
line: "{{ item.mip + ' ' + hostvars[item.aname].default_etc_hosts }}"
75+
state: present
7276
with_items: "{{ ip_2_change }}"
73-
when: ip_2_change is defined and (item.aip is search("192.168.64.x"))
77+
when: ip_2_change is defined

0 commit comments

Comments
 (0)