- hosts: localhost
  tasks:

  - name: Add variables to bashrc file for {{ ansible_env.USER }}
    lineinfile: dest=/home/{{ ansible_env.USER }}/.bashrc regexp="{{ item }}" line="{{ item }}" state=present
    with_items:
      - export AWS_DEFAULT_REGION="eu-west-1"
      - export vpc_destination_variable="private_ip_address"

#  - name: Create .bash_aliases file
#    state: present
#    file: path=/home/theodore/.bash_aliases state=touch owner=theodore group=theodore mode=0644

  - name: Create .bash_aliases file
    copy:
      content: ""
      dest: /home/{{ ansible_env.USER }}/.bash_aliases
      force: no
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: 0644

  - name: Add aliases to bashrc file
    lineinfile: dest=/home/{{ ansible_env.USER }}/.bash_aliases regexp="{{ item }}" line="{{ item }}" state=present
    with_items:
      - alias goipt="cd ~/work/home/ipt/shell"
      - alias ptf="cd ~/work/work/tdcs/workspace/PTF"
      - alias sqlplus="~/opt/sqlcl/bin/sql"
      - alias k9s="~/tools/k9s/k9s"

  - name: Install Apt Packages
    become: yes
    apt:
      state: present
      name:
        - awscli
        - resolvconf
        - sshpass
        - openvpn
        - maven
        - dos2unix
        - pandoc
        - exiv2
        - imagemagick
        - texlive-latex-base
        - texlive-latex-extra
        - oathtool

  - name: Copy vault
    become: yes
    copy:
      src: /home/{{ ansible_env.USER }}/tools/vault/vault
      dest: /usr/local/bin/
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: '0775'
      force: no

  - name: Copy GPG
    copy:
      src: ../../ipt/env/dot_gnupg
      dest: /home/{{ ansible_env.USER }}/.gnupg
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      force: no

  - name: Set upm run permissions
    file:
      path: ~/tools/upm-1.15.1/upm.sh
      mode: u+x
      state: touch
      force: no
    tags:
      - upmlocal
      - never

  - name: Set upm run permissions C drive
    file:
      path: /mnt/c/tools/upm-1.15.1/upm.sh
      mode: u+x
      state: touch
      force: no
    tags:
      - upmlocal
      - never

  - name: Copy upm config
    copy:
      src: ./dot_config/upm.properties
      dest: ~/.config/upm.properties
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: '0664'
      force: no
    tags:
      - upmlocal
      - never


  - name: Install kubeconfig
    become: yes
    get_url:
      url: https://dl.k8s.io/release/v1.18.0/bin/linux/amd64/kubectl
      dest: /usr/local/bin/kubectl
      force: no
      mode: '0755'

  - name: Setup kubeconfig make dir
    file:
      path: /home/{{ ansible_env.USER }}/.kube
      state: directory
      force: no

  - name: Setup kubeconfig copy files
    copy:
      src: ../../ipt/env/kubectl_202101.cfg
      dest: ~/.kube/config
      force: no
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: 0644

  - name: Setup ssh mapping files
    become: yes
    copy:
      src: ./root/etc/ssh/ssh_config
      dest: /etc/ssh/ssh_config
      force: yes
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: 0644

  - name: Setup ssh dir
    file:
      path: /home/{{ ansible_env.USER }}/.ssh
      state: directory
      force: no

  - name: Setup ssh access files
    copy:
      src: ../.ssh/id_rsa
      dest: /home/{{ ansible_env.USER }}/.ssh/id_rsa
      force: no
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: 0600

  - name: Setup ssh access files
    copy:
      src: ../.ssh/id_rsa.pub
      dest: /home/{{ ansible_env.USER }}/.ssh/id_rsa.pub
      force: no
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: 0600


  - name: Set SoapUI run permissions
    file:
      path: /home/{{ ansible_env.USER }}/tools/SmartBear/SoapUI-5.6.0/bin/SoapUI-5.6.0
      mode: u+x
      state: touch
      force: no

  - name: Copy Desktop files
    copy:
      src: ./Desktop/SoapUI 5.6.0.desktop
      dest: /home/{{ ansible_env.USER }}/Desktop/
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: '0775'
      force: no
    tags:
      - desktop
      - never

  - name: Set Jmeter3.3 run permissions
    file:
      path: /home/{{ ansible_env.USER }}/tools/apache-jmeter-3.3/bin/jmeter.sh
      mode: u+x
      state: touch
      force: no

  - name: Set Jmeter3.3 run permissions
    file:
      path: /home/{{ ansible_env.USER }}/tools/apache-jmeter-3.3/bin/jmeter
      mode: u+x
      state: touch
      force: no

  - name: Set Jmeter5.3 run permissions
    file:
      path: /home/{{ ansible_env.USER }}/tools/apache-jmeter-5.3/bin/jmeter.sh
      mode: u+x
      state: touch
      force: no

  - name: Set Jmeter5.3 run permissions
    file:
      path: /home/{{ ansible_env.USER }}/tools/apache-jmeter-5.3/bin/jmeter
      mode: u+x
      state: touch
      force: no

  - name: Set sqldeveloper run permissions
    file:
      path: /home/{{ ansible_env.USER }}/opt/sqldeveloper/sqldeveloper.sh
      mode: u+x
      state: touch
      force: no

  - name: Copy Desktop files
    copy:
      src: ./Desktop/JMeter 3.3.desktop
      dest: /home/{{ ansible_env.USER }}/Desktop/JMeter 3.3.desktop
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: '0775'
      force: no
    tags:
      - desktop
      - never

  - name: Copy Desktop files
    copy:
      src: ./Desktop/JMeter 5.3.desktop
      dest: /home/{{ ansible_env.USER }}/Desktop/JMeter 5.3.desktop
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: '0775'
      force: no
    tags:
      - desktop
      - never

  - name: Copy Desktop files
    copy:
      src: ./Desktop/sqldeveloper.desktop
      dest: /home/{{ ansible_env.USER }}/Desktop/
      owner: "{{ ansible_env.USER }}"
      group: "{{ ansible_env.USER }}"
      mode: '0775'
      force: no
    tags:
      - desktop
      - never

  - name: Install VeraCrypt
    become: yes
    apt:
      deb: /home/{{ ansible_env.USER }}/tools/veracrypt-console-1.25.9-Ubuntu-20.04-amd64.deb
    tags:
      - security
      - never

  - name: "Add nodejs apt key"
    become: yes
    apt_key:
      url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
      state: present
    tags:
      - testtools
      - never

  - name: "Add nodejs 14.x ppa for apt repo"
    become: yes
    apt_repository:
      repo: deb https://deb.nodesource.com/node_14.x bionic main
      update_cache: yes
    tags:
      - testtools
      - never

  - name: Install Test Tools
    become: yes
    apt:
      state: present
      name:
        - nodejs
        - nmap
    tags:
      - testtools
      - never
