Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3745083
D2393.id6060.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D2393.id6060.diff
View Options
diff --git a/_modules/rust.py b/_modules/rust.py
new file mode 100755
--- /dev/null
+++ b/_modules/rust.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+# -------------------------------------------------------------
+# Salt — Rust module
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Description: Provide support for Rust properties
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+
+from salt.utils.path import which as path_which
+
+
+def __virtual__():
+ """
+ Only load if the Rust compiler is available
+ """
+ return path_which('rustc') is not None,\
+ "The Rust execution module cannot be loaded: rustc not installed."
+
+
+def get_rustc_triplet():
+ """
+ A function to get a node triplet for Rust toolchains.
+
+ CLI Example:
+
+ salt * rust.get_rustc_triplet
+ """
+
+ # Thanks to @semarie for that tip.
+ return __salt__['cmd.shell']("rustc -vV | sed -ne 's/^host: //p'")
diff --git a/_tests/modules/test_rust.py b/_tests/modules/test_rust.py
new file mode 100644
--- /dev/null
+++ b/_tests/modules/test_rust.py
@@ -0,0 +1,14 @@
+from importlib.machinery import SourceFileLoader
+import unittest
+
+
+salt_test_case = SourceFileLoader('salt_test_case', "salt_test_case.py").load_module()
+rust = SourceFileLoader('rust', "../_modules/rust.py").load_module()
+
+
+class Testinstance(unittest.TestCase, salt_test_case.SaltTestCase):
+
+ def test_get_rustc_triplet(self):
+ triplet = rust.get_rustc_triplet()
+
+ self.assertTrue(len(triplet.split("-")) > 2)
diff --git a/pillar/core/users.sls b/pillar/core/users.sls
--- a/pillar/core/users.sls
+++ b/pillar/core/users.sls
@@ -117,6 +117,7 @@
devserver_tasks:
- deploy_dotfiles
- deploy_nanotab
+ - install_rustup
uid: 5001
erol:
diff --git a/roles/devserver/userland-home/homefiles.sls b/roles/devserver/userland-home/homefiles.sls
--- a/roles/devserver/userland-home/homefiles.sls
+++ b/roles/devserver/userland-home/homefiles.sls
@@ -7,6 +7,7 @@
# -------------------------------------------------------------
{% from "map.jinja" import dirs with context %}
+{% set triplet = salt['rust.get_rustc_triplet']() %}
{% for username, user in salt['forest.get_users']().items() %}
{% set tasks = user.get('devserver_tasks', []) %}
@@ -37,4 +38,14 @@
- unset tabstospaces
{% endif %}
+{% if 'install_rustup' in tasks %}
+{% for toolchain in ['stable', 'nightly'] %}
+devserver_rustup_{{toolchain}}_{{username}}:
+ cmd.run:
+ - name: rustup install {{ toolchain }}
+ - runas: {{ username }}
+ - creates: /home/{{ username }}/.rustup/toolchains/{{ toolchain }}-{{ triplet }}
+{% endfor %}
+{% endif %}
+
{% endfor %}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 11:56 (20 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2247501
Default Alt Text
D2393.id6060.diff (2 KB)
Attached To
Mode
D2393: Provision Rust development environment
Attached
Detach File
Event Timeline
Log In to Comment