-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to write settings.json (#33)
Write the `settings.json` for the user based on configuration supplied in the playbook. Enhancement: resolves #32
- Loading branch information
Showing
6 changed files
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
- include: install.yml | ||
|
||
- include: install-extensions.yml | ||
|
||
- include: write-settings.yml |
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,22 @@ | ||
--- | ||
- name: create settings directory | ||
become: yes | ||
file: | ||
path: '~{{ item.username }}/.config/Code/User' | ||
state: directory | ||
owner: '{{ item.username }}' | ||
group: '{{ item.username }}' | ||
mode: 'u=rwx,go=' | ||
with_items: '{{ users }}' | ||
|
||
- name: write settings | ||
become: yes | ||
template: | ||
src: settings.json.j2 | ||
dest: '~{{ item.username }}/.config/Code/User/settings.json' | ||
force: no | ||
owner: '{{ item.username }}' | ||
group: '{{ item.username }}' | ||
mode: 'u=rw,go=' | ||
with_items: '{{ users }}' | ||
when: "item.visual_studio_code_settings is defined and item.visual_studio_code_settings not in ({}, '', None, omit)" |
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,2 @@ | ||
// Place your settings in this file to overwrite the default settings | ||
{{ item.visual_studio_code_settings | to_nice_json }} |
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,14 @@ | ||
from testinfra.utils.ansible_runner import AnsibleRunner | ||
|
||
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') | ||
|
||
|
||
def test_settings(File): | ||
settings_file = File('/home/test_usr/.config/Code/User/settings.json') | ||
|
||
assert settings_file.exists | ||
assert settings_file.is_file | ||
assert settings_file.user == 'test_usr' | ||
assert settings_file.group == 'test_usr' | ||
assert oct(settings_file.mode) == '0600' | ||
assert settings_file.contains('"Vagrantfile": "ruby"') |