Skip to content

Commit a3b68cc

Browse files
committed
bind opensearch to localhost, using host networking for containers
1 parent eb28045 commit a3b68cc

File tree

7 files changed

+11
-21
lines changed

7 files changed

+11
-21
lines changed

ansible/roles/filebeat/templates/filebeat.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ After=network-online.target
1313
Environment=PODMAN_SYSTEMD_UNIT=%n
1414
Restart=always
1515
ExecStart=/usr/bin/podman run \
16-
--network slirp4netns:cidr={{ podman_cidr }} \
16+
--network=host \
1717
--sdnotify=conmon --cgroups=no-conmon --replace --name filebeat --user root --restart=always --security-opt label=disable \
1818
--volume /var/log/:/logs:ro \
1919
--volume /etc/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro \

ansible/roles/opensearch/templates/opensearch.service.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ Restart=always
1212
# paths below based on https://opensearch.org/docs/latest/opensearch/configuration/ and https://opensearch.org/docs/latest/security-plugin/configuration/yaml
1313
# see also https://opensearch.org/docs/2.0/opensearch/install/important-settings/
1414
ExecStart=/usr/bin/podman run \
15-
--network slirp4netns:cidr={{ podman_cidr }} \
15+
--network=host \
1616
--sdnotify=conmon --cgroups=no-conmon -d --replace --name opensearch --restart=no --user opensearch \
1717
--ulimit memlock=-1:-1 --ulimit nofile=65536:65536 \
1818
--volume {{ opensearch_data_path }}:/usr/share/opensearch/data:U \
1919
--volume /etc/opensearch/internal_users.yml:/usr/share/opensearch/config/opensearch-security/internal_users.yml:ro \
2020
--volume /etc/opensearch/opensearch.yml:/usr/share/opensearch/config/opensearch.yml \
2121
--env node.name=opensearch --env discovery.type=single-node --env bootstrap.memory_lock=true --env "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" \
22-
--publish 9200:9200 opensearchproject/opensearch:{{ opensearch_version }}
22+
--publish {{ opensearch_address }}:9200:9200 opensearchproject/opensearch:{{ opensearch_version }}
2323
ExecStop=/usr/bin/podman stop --ignore opensearch -t 10
2424
# note for some reason this returns status=143 which makes systemd show the unit as failed, not stopped
2525
ExecStopPost=/usr/bin/podman rm --ignore -f opensearch

ansible/roles/podman/tasks/validate.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,3 @@
77
assert:
88
that: podman_tmp_fstype.stdout == 'tmpfs'
99
fail_msg: "{{ podman_tmp_fstype }} (variable podman_tmp_fstype) must be on tmpfs"
10-
11-
- name: Check host IPs are not within podman network CIDR
12-
assert:
13-
that: ( podman_cidr | ansible.netcommon.network_in_network(item)) == false
14-
fail_msg: "Address {{ item }} for {{ inventory_hostname }} is in podman network range {{ podman_cidr }} - set `podman_cidr` to avoid host network address ranges"
15-
loop: "{{ ansible_all_ipv4_addresses }}"

environments/common/inventory/group_vars/all/defaults.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ internal_address: "{{ inventory_hostname }}"
1212
api_address: "{{ inventory_hostname }}"
1313

1414
# Service endpoints
15-
opensearch_address: "{{ hostvars[groups['opensearch'].0].api_address }}"
15+
opensearch_address: "127.0.0.1"
1616
prometheus_address: "{{ hostvars[groups['prometheus'].0].api_address }}"
1717
openondemand_address: "{{ hostvars[groups['openondemand'].0].api_address if groups['openondemand'] | count > 0 else '' }}"
1818
grafana_address: "{{ hostvars[groups['grafana'].0].api_address }}"
1919

2020
############################# bootstrap: local user configuration #########################
2121

22-
appliances_local_users_default: "{{ ([appliances_local_users_podman] if appliances_local_users_podman_enable else []) + [appliances_local_users_ansible_user] + appliances_local_users_extra }}"
22+
appliances_local_users_default: "{{ ([appliances_local_users_podman] if (groups['podman'] | length > 0) else []) + [appliances_local_users_ansible_user] + appliances_local_users_extra }}"
2323

2424
# Overide this to add extra users whilst keeping the defaults.
2525
appliances_local_users_extra: []
@@ -33,13 +33,12 @@ appliances_local_users_ansible_user:
3333
move_home: true
3434
local: true
3535

36-
appliances_local_users_podman_enable: "{{ groups['podman'] | length > 0 }}"
3736
appliances_local_users_podman_home: /var/lib/podman
3837
appliances_local_users_podman:
39-
- name: podman
40-
comment: Used for running all containers
41-
# Would like to set subuid so that we that we know what will appear in /etc/subuid
42-
# See: https://github.com/ansible/ansible/issues/68199
43-
home: "{{ appliances_local_users_podman_home }}"
38+
name: podman
39+
comment: Used for running all containers
40+
# Would like to set subuid so that we that we know what will appear in /etc/subuid
41+
# See: https://github.com/ansible/ansible/issues/68199
42+
home: "{{ appliances_local_users_podman_home }}"
4443

4544
###########################################################################################
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
podman_users: "{{ appliances_local_users_podman }}" # user to use for podman
2-
podman_cidr: 10.0.2.0/24 # IP range to use for podman - see slirp4netns:cidr= at https://docs.podman.io/en/latest/markdown/podman-run.1.html
1+
podman_users: "{{ [appliances_local_users_podman] }}" # user to use for podman

environments/smslabs/inventory/group_vars/podman/overrides.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

environments/vagrant-example/inventory/group_vars/podman/overrides.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)