-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Detect terraform usage, use dynamic inventory - AWS template: use SES for emails - Barebone, local template updates - LDAP: self-service email reset - Grafana: always use SSL - Grafana: email config - Portainer: new role - Fix: swarm auth health check
- Loading branch information
Showing
28 changed files
with
498 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
portainer_version: "1.19.2" | ||
|
||
portainer_endpoint: "portainer.{{ local_domain_name }}" | ||
portainer_whitelist: "0.0.0.0/0" | ||
portainer_stack: "portainer" | ||
portainer_stack_file: "/opt/dawn/portainer.yml" | ||
|
||
portainer_admin_username: "admin" | ||
portainer_admin_password: "RkhGg!,n4JM.SqcTV>4r@sEM" | ||
|
||
portainer_allow_bindmounts_users: true | ||
portainer_allow_privileged_users: true | ||
|
||
docker_client_key_file: /etc/ssl/certs/docker/client.key.pem | ||
docker_client_cert_file: /etc/ssl/certs/docker/client.cert.pem | ||
docker_client_ca_file: /etc/ssl/certs/docker/client.ca.pem | ||
|
||
ldap_server: "{{ group_ipv4.control[0] }}" | ||
ldap_server_port: 389 | ||
ldap_dc: "dc={{ local_domain_name.split('.') | join(',dc=') }}" | ||
ldap_admin_user: "cn=admin,{{ ldap_dc }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
- import_tasks: server.yml | ||
when: groups['control'][0] == inventory_hostname | ||
|
||
- name: "Generate authentication token" | ||
uri: | ||
url: "https://{{ portainer_endpoint }}/api/auth" | ||
method: POST | ||
return_content: yes | ||
body_format: json | ||
body: '{ "Username":"{{ portainer_admin_username }}", "Password":"{{ portainer_admin_password }}"}' | ||
register: auth_token | ||
|
||
- name: "Check if endpoint is registered" | ||
warn: false | ||
shell: | | ||
curl "https://{{ portainer_endpoint }}/api/endpoints" \ | ||
-XGET \ | ||
-H "Authorization: {{ (auth_token.content|from_json).jwt }}" | ||
register: portainer_endpoints | ||
changed_when: > | ||
portainer_endpoints.stdout | ||
|from_json | ||
|selectattr("Name", "equalto", inventory_hostname) | ||
|list | ||
|length == 0 | ||
- name: "Register endpoint" | ||
warn: false | ||
shell: | | ||
curl "https://{{ portainer_endpoint }}/api/endpoints" \ | ||
-XPOST \ | ||
-H "Authorization: {{ (auth_token.content|from_json).jwt }}" \ | ||
-F "Name={{ inventory_hostname }}" \ | ||
-F "EndpointType=1" \ | ||
-F "URL=tcp://{{ private_ipv4 + ":2376" }}" \ | ||
-F "PublicURL={{ private_ipv4 + ":2376" }}" \ | ||
-F "TLS=true" \ | ||
-F "TLSSkipVerify=false" \ | ||
-F "TLSSkipClientVerify=false" \ | ||
-F "TLSCACertFile=@{{ docker_client_ca_file }}" \ | ||
-F "TLSCertFile=@{{ docker_client_cert_file }}" \ | ||
-F "TLSKeyFile=@{{ docker_client_key_file }}" | ||
when: portainer_endpoints.changed|bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
- name: "Create portainer stack file" | ||
template: | ||
dest: "{{ portainer_stack_file }}" | ||
src: "portainer_stack.yml.j2" | ||
register: portainer_stack_file_status | ||
|
||
- name: "Check if portainer is running" | ||
shell: "docker stack ps {{ portainer_stack }}" | ||
changed_when: portainer_running_state.rc != 0 | ||
ignore_errors: yes | ||
register: portainer_running_state | ||
|
||
- name: "Start portainer on the cluster" | ||
when: > | ||
portainer_running_state.changed|bool | ||
or portainer_stack_file_status.changed|bool | ||
shell: "docker stack deploy -c '{{ portainer_stack_file }}' {{ portainer_stack }}" | ||
|
||
- name: "Check if we will need to create admin user" | ||
uri: | ||
url: "https://{{ portainer_endpoint }}/api/auth" | ||
method: POST | ||
return_content: yes | ||
body_format: json | ||
body: '{ "Username":"{{ portainer_admin_username }}", "Password":"{{ portainer_admin_password }}"}' | ||
changed_when: portainer_create_user|failed | ||
register: portainer_create_user | ||
ignore_errors: true | ||
|
||
- name: "Configure admin user password" | ||
uri: | ||
url: "https://{{ portainer_endpoint }}/api/users/admin/init" | ||
method: POST | ||
return_content: yes | ||
body_format: json | ||
body: '{ "Username":"{{ portainer_admin_username }}", "Password":"{{ portainer_admin_password }}"}' | ||
when: portainer_create_user.changed|bool | ||
register: portainer_user_created | ||
retries: 10 | ||
delay: 10 | ||
until: portainer_user_created|success | ||
|
||
- name: "Generate authentication token" | ||
uri: | ||
url: "https://{{ portainer_endpoint }}/api/auth" | ||
method: POST | ||
return_content: yes | ||
body_format: json | ||
body: '{ "Username":"{{ portainer_admin_username }}", "Password":"{{ portainer_admin_password }}"}' | ||
register: auth_token | ||
|
||
- name: "Configure portainer settings" | ||
uri: | ||
url: "https://{{ portainer_endpoint }}/api/settings" | ||
method: PUT | ||
return_content: yes | ||
headers: | ||
Authorization: "{{ (auth_token.content|from_json).jwt }}" | ||
body_format: json | ||
body: "{{ lookup('template','settings.json.j2') }}" |
37 changes: 37 additions & 0 deletions
37
docker-image/ansible/roles/portainer/templates/portainer_stack.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: '3' | ||
|
||
volumes: | ||
portainer_data: | ||
|
||
networks: | ||
prometheus: | ||
external: | ||
name: prometheus_net | ||
traefik: | ||
external: | ||
name: traefik_net | ||
|
||
services: | ||
portainer: | ||
image: portainer/portainer:{{ portainer_version }} | ||
command: -H unix:///var/run/docker.sock | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- portainer_data:/data | ||
networks: | ||
- prometheus | ||
- traefik | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: on-failure | ||
placement: | ||
constraints: | ||
- engine.labels.dawn.node.type == control | ||
labels: | ||
traefik.port: 9000 | ||
traefik.frontend.rule: "Host: {{ portainer_endpoint }}" | ||
traefik.frontend.whitelist.sourceRange: "{{ portainer_whitelist }}" | ||
traefik.frontend.headers.SSLRedirect: "true" | ||
traefik.backend.loadbalancer.stickiness: "true" | ||
traefik.docker.network: traefik_net |
7 changes: 7 additions & 0 deletions
7
docker-image/ansible/roles/portainer/templates/registry.json.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"Name": "Dawn Registry", | ||
"URL": "{{ registry_url }}:{{ registry_port }}", | ||
"Authentication": true, | ||
"Username": "{{ registry_username }}", | ||
"Password": "{{ registry_password }}" | ||
} |
38 changes: 38 additions & 0 deletions
38
docker-image/ansible/roles/portainer/templates/settings.json.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
{% if portainer_templates_url is defined %} | ||
"TemplatesURL": "{{ portainer_templates_url }}", | ||
{% endif %} | ||
{% if portainer_company_logo_url is defined %} | ||
"LogoURL": "{{ portainer_company_logo_url }}", | ||
{% endif %} | ||
"DisplayDonationHeader": false, | ||
"DisplayExternalContributors": true, | ||
"AuthenticationMethod": 2, | ||
"LDAPSettings": { | ||
"ReaderDN": "{{ ldap_admin_user }}", | ||
"Password": "{{ ldap_admin_password }}", | ||
"URL": "{{ ldap_server }}:{{ ldap_server_port }}", | ||
"TLSConfig": { | ||
"TLS": false, | ||
"TLSSkipVerify": true | ||
}, | ||
"StartTLS": false, | ||
"SearchSettings": [ | ||
{ | ||
"BaseDN": "ou=users,{{ ldap_dc }}", | ||
"Filter": "", | ||
"UserNameAttribute": "uid" | ||
} | ||
], | ||
"GroupSearchSettings": [ | ||
{ | ||
"GroupBaseDN": "ou=groups,{{ ldap_dc }}", | ||
"GroupFilter": "", | ||
"GroupAttribute": "cn" | ||
} | ||
], | ||
"AutoCreateUsers": true | ||
}, | ||
"AllowBindMountsForRegularUsers": {{ portainer_allow_bindmounts_users }}, | ||
"AllowPrivilegedModeForRegularUsers": {{ portainer_allow_privileged_users }} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.