Skip to content

Commit

Permalink
Merge pull request #244 from python/generate_automated_server_list
Browse files Browse the repository at this point in the history
Generate template for automated server list
  • Loading branch information
cegerhardson committed Jul 6, 2022
2 parents 6636681 + 6d5ce4e commit a8e628d
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 7 deletions.
4 changes: 1 addition & 3 deletions docs/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ Server List
Hosts managed by Salt
---------------------

This list is automatically generated by our salt server.

TODO: Add a reference to the tool that generates the list!
This list is `automatically generated <https://github.com/python/psf-salt/blob/66bfe549a281de775551ab94861328ccd7d47467/salt/base/config/salt-server-list.rst.jinja#L12-L17>`_ by our salt server.

..
START AUTOMATED SECTION **DO NOT DIRECTLY EDIT - Salt will blow away your changes!!!**
Expand Down
4 changes: 4 additions & 0 deletions pillar/dev/networking.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ psf_internal_network: &psf_internal_network 192.168.50.0/24


mine_functions:
psf_dc:
- mine_function: pillar.get
- dc

psf_internal:
mine_function: network.ip_addrs
cidr: *psf_internal_network
Expand Down
4 changes: 2 additions & 2 deletions pillar/dev/roles.sls
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ roles:
contact: ""
docs:
pattern: "docs.vagrant.psf.io"
purpose: ""
contact: ""
purpose: "Builds and serves CPython's documentation"
contact: "mdk"
downloads:
pattern: "downloads.vagrant.psf.io"
purpose: ""
Expand Down
4 changes: 4 additions & 0 deletions pillar/prod/networking.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ psf_internal_network: &psf_internal_network 10.132.0.0/16


mine_functions:
psf_dc:
- mine_function: pillar.get
- dc

psf_internal:
mine_function: network.ip_addrs
cidr: *psf_internal_network
Expand Down
2 changes: 1 addition & 1 deletion pillar/prod/roles.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ roles:
contact: ""
consul:
pattern: "consul*.nyc1.psf.io"
purpose: "Runs '<https://www.consul.io/service>' discovery"
purpose: "Runs `Consul <https://www.consul.io/>`_ discovery service"
contact: "Infrastructure Staff"
docs:
pattern: "docs.nyc1.psf.io"
Expand Down
20 changes: 20 additions & 0 deletions salt/base/config/salt-server-list.rst.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
..
START AUTOMATED SECTION **DO NOT DIRECTLY EDIT - Salt will blow away your changes!!!**

{% set role_mapping = {} -%}
{% for role, config in salt["pillar.get"]("roles", {}).items() -%}
{% set x=role_mapping.__setitem__(config["pattern"], role) -%}
{% endfor %}

.. csv-table::
:header: "Name", "Purpose", "Contact", "Datacener"

{% for server in salt['minion.list']()['minions']|sort -%}
{% set role = salt['match.filter_by'](role_mapping, minion_id=server) -%}
{% set datacenter = salt['mine.get']("*", "psf_dc").get(server, "") -%}
{% set roleconfig = salt["pillar.get"]("roles", {}).get(role, {}) %}
"{{ server }}", "{{ roleconfig.get("purpose", "") }}", "{{ roleconfig.get("contact", "") }}", "{{ datacenter }}"
{%- endfor %}

..
END AUTOMATED SECTION **DO NOT DIRECTLY EDIT - Salt will blow away your changes!!!**
8 changes: 8 additions & 0 deletions salt/base/salt.sls
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ salt-master:
- user: root
- group: root
- mode: 644

/srv/salt-server-list.rst:
file.managed:
- source: salt://base/config/salt-server-list.rst.jinja
- template: jinja
- user: root
- group: root
- mode: 644
{% endif %}

salt-minion-pkg:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ skipsdist = true
deps =
sphinx
sphinx_rtd_theme
basepython = python2.7
basepython = python3
commands =
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html

0 comments on commit a8e628d

Please sign in to comment.