Loading playbooks/group_vars/all.yml +7 −2 Original line number Diff line number Diff line Loading @@ -18,5 +18,10 @@ kubeadmin_config: /etc/kubernetes/admin.conf helm_version: "3.3/stable" # Go #go_version: "1.13.12" #golangci_lint_version: "v1.18.0" No newline at end of file go_version: "1.15.3" golangci_lint_version: "v1.18.0" # Node and NPM node_version: "10.16.3" npm_version: "6.14.8" eslint_version: "5.16.0" No newline at end of file playbooks/hosts.ini +4 −0 Original line number Diff line number Diff line Loading @@ -11,3 +11,7 @@ [cluster:children] master worker # AdvantEDGE development machine [dev] #dev1 ansible_host=<dev IP addr> ansible_user=<username> No newline at end of file playbooks/install-development-env.yml 0 → 100644 +13 −0 Original line number Diff line number Diff line --- - hosts: dev gather_facts: yes become: yes roles: - { role: golang, tags: golang } - hosts: dev gather_facts: yes become: yes roles: - { role: node, tags: node } playbooks/roles/golang/tasks/install.yml +26 −7 Original line number Diff line number Diff line --- - name: Download Go binaries Loading @@ -15,23 +14,43 @@ - name: Create Go working directory become: false file: path: "~/gocode/bin/" path: "/home/{{ ansible_user }}/gocode/bin/" state: directory - name: Update profile gopath become: false lineinfile: dest: ~/.profile dest: /home/{{ ansible_user }}/.profile state: present line: 'export GOPATH=$HOME/gocode' - name: Update profile path become: false lineinfile: dest: ~/.profile dest: /home/{{ ansible_user }}/.profile state: present line: 'export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin' # - name: Install golangci-lint # become: false # shell: "cd ~; GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@{{golangci_lint_version}}" - name: Install golangci-lint become: false shell: "cd /home/{{ ansible_user }}/; source /home/{{ ansible_user }}/.profile; GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@{{golangci_lint_version}}" args: executable: /bin/bash # source .bashrc doesn't work so added golang part in .profile. But .profile # only works if logging into the machine remotely or use login shell option is # selected in terminal preferences. So adding it in .profile and .bashrc both. - name: Update bashrc gopath become: false lineinfile: dest: /home/{{ ansible_user }}/.bashrc state: present line: 'export GOPATH=$HOME/gocode' - name: Update bashrc path become: false lineinfile: dest: /home/{{ ansible_user }}/.bashrc state: present line: 'export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin' playbooks/roles/golang/tasks/main.yml +13 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,18 @@ - ansible_distribution_version == '18.04' quiet: yes - name: Install Go - name: Check if golang is installed command: /bin/bash -c "source /home/{{ ansible_user }}/.profile; go version | awk '{print $3}' | cut -c 3-" register: go_check failed_when: "'command not found' in go_check.stdout" - debug: msg: "[WARNING] Current golang version is lower than recommended version {{ go_version }}.\n To get the script to install properly, uninstall the existing golang and rerun script.\n Also remove all its dependencies and config/data." when: go_check.stdout != '' and go_check.stdout is version_compare(go_version, '<') - name: Install golang if go command not found include_tasks: file: install.yml when: go_check.stdout == '' Loading
playbooks/group_vars/all.yml +7 −2 Original line number Diff line number Diff line Loading @@ -18,5 +18,10 @@ kubeadmin_config: /etc/kubernetes/admin.conf helm_version: "3.3/stable" # Go #go_version: "1.13.12" #golangci_lint_version: "v1.18.0" No newline at end of file go_version: "1.15.3" golangci_lint_version: "v1.18.0" # Node and NPM node_version: "10.16.3" npm_version: "6.14.8" eslint_version: "5.16.0" No newline at end of file
playbooks/hosts.ini +4 −0 Original line number Diff line number Diff line Loading @@ -11,3 +11,7 @@ [cluster:children] master worker # AdvantEDGE development machine [dev] #dev1 ansible_host=<dev IP addr> ansible_user=<username> No newline at end of file
playbooks/install-development-env.yml 0 → 100644 +13 −0 Original line number Diff line number Diff line --- - hosts: dev gather_facts: yes become: yes roles: - { role: golang, tags: golang } - hosts: dev gather_facts: yes become: yes roles: - { role: node, tags: node }
playbooks/roles/golang/tasks/install.yml +26 −7 Original line number Diff line number Diff line --- - name: Download Go binaries Loading @@ -15,23 +14,43 @@ - name: Create Go working directory become: false file: path: "~/gocode/bin/" path: "/home/{{ ansible_user }}/gocode/bin/" state: directory - name: Update profile gopath become: false lineinfile: dest: ~/.profile dest: /home/{{ ansible_user }}/.profile state: present line: 'export GOPATH=$HOME/gocode' - name: Update profile path become: false lineinfile: dest: ~/.profile dest: /home/{{ ansible_user }}/.profile state: present line: 'export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin' # - name: Install golangci-lint # become: false # shell: "cd ~; GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@{{golangci_lint_version}}" - name: Install golangci-lint become: false shell: "cd /home/{{ ansible_user }}/; source /home/{{ ansible_user }}/.profile; GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@{{golangci_lint_version}}" args: executable: /bin/bash # source .bashrc doesn't work so added golang part in .profile. But .profile # only works if logging into the machine remotely or use login shell option is # selected in terminal preferences. So adding it in .profile and .bashrc both. - name: Update bashrc gopath become: false lineinfile: dest: /home/{{ ansible_user }}/.bashrc state: present line: 'export GOPATH=$HOME/gocode' - name: Update bashrc path become: false lineinfile: dest: /home/{{ ansible_user }}/.bashrc state: present line: 'export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin'
playbooks/roles/golang/tasks/main.yml +13 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,18 @@ - ansible_distribution_version == '18.04' quiet: yes - name: Install Go - name: Check if golang is installed command: /bin/bash -c "source /home/{{ ansible_user }}/.profile; go version | awk '{print $3}' | cut -c 3-" register: go_check failed_when: "'command not found' in go_check.stdout" - debug: msg: "[WARNING] Current golang version is lower than recommended version {{ go_version }}.\n To get the script to install properly, uninstall the existing golang and rerun script.\n Also remove all its dependencies and config/data." when: go_check.stdout != '' and go_check.stdout is version_compare(go_version, '<') - name: Install golang if go command not found include_tasks: file: install.yml when: go_check.stdout == ''