Skip to content
Snippets Groups Projects
ubuntu-shellinabox.yaml 2.35 KiB
Newer Older
Laurent Modolo's avatar
Laurent Modolo committed
- hosts: all
  tasks:

  - name: Update the system
    apt:
      upgrade: dist

  - name: Install requirements
    apt:
      name: 
        - autofs
        - fail2ban
        - python3-pip
        - nfs-common
        - jq
        - openssl
        - shellinabox
      state: latest

  - name: Remove old Docker version
    apt:
      name:
        - docker
        - docker-engine
        - docker.io
        - containerd
        - runc
      state: absent

  - name: Install Docker deps
    apt:
      name:
        - apt-transport-https
        - ca-certificates
        - curl
        - gnupg-agent
        - software-properties-common
      state: latest

  - name: Add Docker’s official GPG key
    apt_key:
      url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
      state: present

  - name: Add Docker's repository into sources list
    apt_repository:
      repo: deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
      state: present

  - name: Install Docker engine community
    apt:
      name:
        - docker-ce
        - docker-ce-cli
        - containerd.io
      state: latest

  - name: Configure shell in a box 
    shell: sed -i 's|SHELLINABOX_PORT=4200|SHELLINABOX_PORT=443|' /etc/default/shellinabox

  - name: Configure network
    shell: iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT && iptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT && iptables-save

  - name: Enable services
    systemd:
      name: "{{ item }}" 
      enabled: yes
      state: started
    loop:
      - docker
      - fail2ban

  - name: Restart services
    systemd:
      name: "{{ item }}" 
      enabled: yes
      state: restarted
    loop:
      - shellinabox 

  - name: Update pip
    pip:
      name: 
        - pip
      executable: pip3
      state: latest

  - name: Install docker-compose
    pip:
      name: 
        - docker-compose
      executable: pip3
      state: latest

  - name: Install Miniconda
    script: miniconda-install.sh

  - name: Copy IFB profile
    copy:
      src: profile_ifb.sh
      dest: /etc/profile.d/ifb.sh
      owner: root
      mode: '0644'

  - name: Create IFB root dir and bin
    shell: . /etc/profile.d/ifb.sh && mkdir -p $IFB_BIN

  - name: Create IFB data dir
    shell: . /etc/profile.d/ifb.sh && mkdir -p $IFB_DATADIR