---
- hosts: lin
  user: root
  handlers:
  - name: "restart ssh"
    service:
      name: sshd
      state: restarted
  vars:
      packages:
      - epel-release
      - python3-firewall
      - python3-libselinux
      - python3-passlib
      - python3-pip
      - bash-completion
      - tmux
      - git
      - vim

  tasks:
  - name: "install epel"
    ansible.builtin.package:
      name: "epel-release"
      state: present

  - name: "install some software"
    ansible.builtin.package:
      name: "{{ packages }}"
      state: present

  - name: "disable selinux"
    block:
    - ansible.posix.selinux:
        state: permissive
        policy: targeted
    tags: selinux

  - name: "configure vim"
    tags: vim
    ansible.builtin.git:
      dest: /tmp/vim
      repo: https://git.opendoor.fr/tom/vim_formation.git

  - name: "configure vim"
    tags: vim
    ansible.builtin.copy:
      src: /tmp/vim/vimrc
      dest: /etc/vimrc
      mode: 0644
      owner: root
      remote_src: true

  - name: get bash config file
    ansible.builtin.get_url:
      url: https://cours.opendoor.fr/LIN/z_my_profile.sh.tt
      dest: /tmp/

  - name: "configure prompt"
    vars:
      usercolor: "\e[0;3{{ 9 | random( seed=inventory_hostname ) }}m"
      hostcolor: "\e[0;4{{ 9 | random( seed=inventory_hostname ) }}m"
    ansible.builtin.template:
      dest: /etc/profile.d/z_my_profile.sh
      src: /tmp/z_my_profile.sh.tt
    tags: shell

  - name: "configure sudo"
    community.general.sudoers:
      name: lin
      user: user
      commands: ALL
      nopassword: true

