Add ansible, create directory structure

This commit is contained in:
Austen Adler 2018-04-07 21:47:15 +00:00
parent 72412817c7
commit cc9072dbc5
24 changed files with 144 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.stfolder
main.retry

2
hosts Normal file
View File

@ -0,0 +1,2 @@
[local]
127.0.0.1

11
main.yml Normal file
View File

@ -0,0 +1,11 @@
---
- hosts: local
become: false
vars:
local_path: '/tmp/eee'
roles:
- {role: core, tags: [default]}
- {role: vim, tags: [vim]}
- {role: youcompleteme, tags: [vim,youcompleteme]}
- {role: secure, sudo: yes, tags: [secure]}
- {role: test, tags: [test]}

25
roles/core/tasks/main.yml Normal file
View File

@ -0,0 +1,25 @@
- name: Create directories
file:
path: "{{ local_path }}/{{ item.path }}"
state: directory
with_filetree: "/skel/"
when: item.state == 'directory'
- name: Link files
file:
#src: "/skel/{{ item }}"
src: "{{ item.src }}"
dest: "{{ local_path }}/{{ item.path }}"
state: link
become: no
with_filetree: "/skel/"
when: item.state == 'file'
- name: Clone fzf
git:
repo: "https://gitea.austenwares.com/stonewareslord/fzf.git"
dest: "{{ local_path }}/.fzf"
clone: yes
update: yes
force: yes
become: no
- name: Install fzf
shell: "{{ local_path|quote }}/.fzf/install --bin"

View File

@ -0,0 +1,32 @@
- name: Protocol 2
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^\s*Protocol\s+2'
# insertbefore: '^\s*Match'
insertbefore: BOF
state: 'present'
line: 'Protocol 2'
- name: UseDNS no
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^\s*UseDNS\s+no'
# insertbefore: '^\s*Match'
insertbefore: BOF
state: 'present'
line: 'UseDNS no'
- name: PermitEmptyPasswords no
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^\s*PermitEmptyPasswords\s+no'
# insertbefore: '^\s*Match'
insertbefore: BOF
state: 'present'
line: 'PermitEmptyPasswords no'
- name: PermitRootLogin without-password
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^\s*PermitRootLogin\s+without-password'
# insertbefore: '^\s*Match'
insertbefore: BOF
state: 'present'
line: 'PermitRootLogin without-password'

View File

@ -0,0 +1,7 @@
- name: Insert test line
lineinfile:
path: /tmp/file
regexp: '^Listen '
insertafter: '^#Listen '
state: 'present'
line: 'Listen 8080'

31
roles/vim/tasks/main.yml Normal file
View File

@ -0,0 +1,31 @@
- name: Link vimrc
file:
#src: "/skel/{{ item }}"
src: "{{ item.src }}"
dest: "{{ local_path }}/{{ item.path }}"
state: link
become: no
with_filetree: "/skel/"
when: item.state == 'file'
- name: Create vim directories
file:
path: "{{ local_path }}/{{ item.path }}"
state: directory
with_filetree: "/skel.vim/"
when: item.state == 'directory'
- name: Install plug
get_url:
url: "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
dest: "{{ local_path }}/.vim/autoload/plug.vim"
- name: Clean plugins
shell: "vim -E -s -c 'source {{ local_path }}/.vimrc' -c PlugClean! -c qa"
# shell: "vim +'silent! PlugClean!' +q!"
ignore_errors: yes
- name: Install plugins
shell: "vim -E -s -c 'source {{ local_path }}/.vimrc' -c PlugInstall! -c qa"
# shell: "vim +'silent! PlugInstall!' +q!"
ignore_errors: yes
- name: Update plugins
shell: "vim -E -s -c 'source {{ local_path }}/.vimrc' -c PlugUpdate! -c qa"
# shell: "vim +'silent! PlugUpdate!' +q!"
ignore_errors: yes

View File

@ -0,0 +1,29 @@
- name: Check if cargo is installed
shell: command -v cargo >/dev/null 2>&1
register: cargo_exists
ignore_errors: yes
- name: Check if go is installed
shell: command -v go >/dev/null 2>&1
register: go_exists
ignore_errors: yes
# TODO: Figure out how to transform cargo_flag.rc == 0 && echo --racer-completer
- name: Install youcompleteme
shell:
cmd: ./install.py
chdir: "~/.vim/plugged/YouCompleteMe"
when: "go_exists.rc != 0 and cargo_exists.rc != 0"
- name: Install youcompleteme with rust
shell:
cmd: ./install.py --racer-completer
chdir: "~/.vim/plugged/YouCompleteMe"
when: "go_exists.rc != 0 and cargo_exists.rc == 0"
- name: Install youcompleteme with go
shell:
cmd: ./install.py --gocode-completer
chdir: "~/.vim/plugged/YouCompleteMe"
when: "go_exists.rc == 0 and cargo_exists.rc != 0"
- name: Install youcompleteme with rust and go
shell:
cmd: ./install.py --gocode-completer --racer-completer
chdir: "~/.vim/plugged/YouCompleteMe"
when: "go_exists.rc == 0 and cargo_exists.rc == 0"

6
sync.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
ansible-playbook -i hosts main.yml --tags default
# Could also sync vim:
# ansible-playbook -i hosts main.yml --tags default,vim
# Could also secure system
# ansible-playbook -i hosts --ask-become-pass main.yml --tags default,vim,secure