Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3746040
D2405.id6046.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D2405.id6046.diff
View Options
diff --git a/_modules/nano.py b/_modules/nano.py
--- a/_modules/nano.py
+++ b/_modules/nano.py
@@ -19,14 +19,18 @@
return ["include " + file for file in process.stdout.split()]
-def _get_rc_content(nanorc_dir):
+def _get_rc_content(nanorc_dir, extra_settings=[]):
nano_rc_includes = _get_rc_includes(nanorc_dir)
+ content = "\n".join(nano_rc_includes) + "\n"
- return "\n".join(nano_rc_includes) + "\n"
+ if extra_settings:
+ content += "\n\n" + "\n".join(extra_settings) + "\n"
+ return content
-def check_rc_up_to_date(name="/etc/nanorc", nanorc_dir="/usr/share/nano"):
- expected_content = _get_rc_content(nanorc_dir)
+
+def check_rc_up_to_date(name="/etc/nanorc", nanorc_dir="/usr/share/nano", extra_settings=[]):
+ expected_content = _get_rc_content(nanorc_dir, extra_settings)
try:
fd = open(name)
@@ -39,8 +43,8 @@
return actual_content == expected_content
-def config_autogenerate(name="/etc/nanorc", nanorc_dir="/usr/share/nano"):
- nano_rc_content = _get_rc_content(nanorc_dir)
+def config_autogenerate(name="/etc/nanorc", nanorc_dir="/usr/share/nano", extra_settings=[]):
+ nano_rc_content = _get_rc_content(nanorc_dir, extra_settings)
fd = open(name, "w")
fd.write(nano_rc_content)
diff --git a/_states/nano.py b/_states/nano.py
--- a/_states/nano.py
+++ b/_states/nano.py
@@ -10,13 +10,13 @@
# -------------------------------------------------------------
-def config_autogenerated(name="/etc/nanorc", nanorc_dir="/usr/share/nano"):
+def config_autogenerated(name="/etc/nanorc", nanorc_dir="/usr/share/nano", extra_settings=[]):
ret = {'name': name,
'result': False,
'changes': {},
'comment': ''}
- if __salt__['nano.check_rc_up_to_date'](name=name, nanorc_dir=nanorc_dir):
+ if __salt__['nano.check_rc_up_to_date'](name=name, nanorc_dir=nanorc_dir, extra_settings=extra_settings):
ret['result'] = True
ret['comment'] = '{0} is already up to date'.format(name)
return ret
@@ -27,7 +27,7 @@
return ret
try:
- __salt__['nano.config_autogenerate'](name=name, nanorc_dir=nanorc_dir)
+ __salt__['nano.config_autogenerate'](name=name, nanorc_dir=nanorc_dir, extra_settings=extra_settings)
except Exception as e:
ret['comment'] = e
return ret
diff --git a/_tests/modules/test_nano.py b/_tests/modules/test_nano.py
--- a/_tests/modules/test_nano.py
+++ b/_tests/modules/test_nano.py
@@ -13,6 +13,10 @@
'include data/nanorc_dir/foo.nanorc',
]
+EXTRA_SETTINGS = ['set foo bar']
+
+EXPECTED_FULL_CONFIG = [''] * 2 + EXPECTED_INCLUDES + EXTRA_SETTINGS
+
class Testinstance(unittest.TestCase, salt_test_case.SaltTestCase):
@@ -21,6 +25,11 @@
self.assertEqual(EXPECTED_INCLUDES,
sorted(actual_includes.strip().split("\n")))
+ def test_get_rc_contents_full(self):
+ actual_includes = nano._get_rc_content(DATA_DIR, extra_settings=EXTRA_SETTINGS)
+ self.assertEqual(EXPECTED_FULL_CONFIG,
+ sorted(actual_includes.strip().split("\n")))
+
def test_get_rc_includes(self):
self.assertEqual(EXPECTED_INCLUDES,
sorted(nano._get_rc_includes(DATA_DIR)))
diff --git a/pillar/core/users.sls b/pillar/core/users.sls
--- a/pillar/core/users.sls
+++ b/pillar/core/users.sls
@@ -116,6 +116,7 @@
- ccccccbjncrt
devserver_tasks:
- deploy_dotfiles
+ - deploy_nanotab
uid: 5001
erol:
diff --git a/roles/devserver/userland-home/files/_tasks/nanotab.sh b/roles/devserver/userland-home/files/_tasks/nanotab.sh
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/_tasks/nanotab.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+nano -f ~/.config/nano/nanorc-tab -w "$@"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/nanotab b/roles/devserver/userland-home/files/dereckson/bin/nanotab
deleted file mode 100755
--- a/roles/devserver/userland-home/files/dereckson/bin/nanotab
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-nano -I -w "$@"
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
@@ -6,8 +6,10 @@
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
+{% from "map.jinja" import dirs with context %}
+
{% for username, user in salt['forest.get_users']().items() %}
-{% set tasks = user.get('devserver_tasks', []) }
+{% set tasks = user.get('devserver_tasks', []) %}
{% if 'deploy_dotfiles' in tasks %}
dotfiles_to_devserver_{{username}}:
@@ -20,4 +22,19 @@
- group: {{ username }}
{% endif %}
+{% if 'deploy_nanotab' in tasks %}
+/home/{{ username }}/bin/nanotab:
+ file.managed:
+ - source: salt://roles/devserver/userland-home/files/_tasks/nanotab.sh
+ - user: {{ username }}
+ - group: {{ username }}
+ - mode: 0755
+
+/home/{{ username }}/.config/nano/nanorc-tab:
+ nano.config_autogenerated:
+ - nanorc_dir: {{ dirs.share }}/nano
+ - extra_settings:
+ - unset tabstospaces
+{% endif %}
+
{% endfor %}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 18:14 (21 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2247914
Default Alt Text
D2405.id6046.diff (5 KB)
Attached To
Mode
D2405: Provide nanotab wrapper for devserver
Attached
Detach File
Event Timeline
Log In to Comment