commit c696a26fd428d3d9a82c6307d5313d03d2a442d1 parent 18d597038bca372c9bc6210f5bcfdc711cde4dba Author: Vincent Demeester <vincent@sbr.pm> Date: Mon, 13 May 2019 00:00:35 +0200 ansible: start spliting playbook into roles… … and do some conditional run too (in case of Fedar vs something else) Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
21 files changed, 375 insertions(+), 33 deletions(-)
diff --git a/bootstrap.sh b/bootstrap.sh @@ -74,6 +74,10 @@ EOF run_home-manager echo ". \"$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh\"" >> $HOME/.bashrc . $HOME/.bashrc + echo "> install ansible" + sudo dnf install -y ansible + echo "> run playbook" + ansible-playbook -K playbook.yml } setup_osx() { diff --git a/playbook.yml b/playbook.yml @@ -0,0 +1,10 @@ +--- +- hosts: localhost + roles: + - common + - desktop + - { role: laptop, when: ansible_form_factor == 'Notebook' } + +# ansible_hostname == 'hokkaido' +# ansible_product_version == 'ThinkPad X220' +# ansible_form_factor == 'Notebook'+ \ No newline at end of file diff --git a/playbook/post_install.retry b/playbook/post_install.retry @@ -1 +0,0 @@ -localhost diff --git a/playbook/post_install.yaml b/playbook/post_install.yaml @@ -1,46 +1,14 @@ -# TODO: create a bootstrap script (fedora, nixos support) -# TODO: tlp, tlp-rdw (+ systemd enabled) – https://www.fosslinux.com/2304/how-to-increase-laptops-battery-life-in-fedora-all-versions.htm -# TODO: powertop (+ systemd enabled) -# TODO: rpm-fusion + stuff – https://rpmfusion.org/Configuration -# TODO: Install nix + home-manager — install commands from README (as user) -# TODO: gedit configuration -# TODO: syncthing + syncthing-gtk + service(s) -# TODO: wireguard — https://github.com/mina-alber/wireguard-ansible -# TODO: fonts (fira-code, hasklig, … ?) – https://github.com/tonsky/FiraCode/wiki/Linux-instructions#fedora -# TODO: yubico -# TODO: fingerprint (hokkaido) -# TODO: compose key (capslock) - hosts: localhost tasks: - name: Install essentials become: yes package: name={{item}} state=present with_items: - - vim - - htop - - tmux - - python3-psutil - dconf-editor - redhat-text-fonts - redhat-display-fonts - mozilla-fira-mono-fonts - mozilla-fira-sans-fonts - - acpi - - name: Enable Night Light - dconf: - key: "/org/gnome/settings-daemon/plugins/color/night-light-enabled" - value: "true" - state: present - - name: Enable Night Light - dconf: - key: "/org/gnome/settings-daemon/plugins/color/night-light-schedule-automatic" - value: "true" - state: present - - name: Enable Night Light - dconf: - key: "/org/gnome/settings-daemon/plugins/color/night-light-temperature" - value: "5000" - state: present - name: Install dev become: yes package: name={{item}} state=present diff --git a/roles/common/tasks/install-essentials.yml b/roles/common/tasks/install-essentials.yml @@ -0,0 +1,8 @@ +--- +- name: Install essentials + become: yes + package: name={{item}} state=present + with_items: + - vim + - htop + - tmux+ \ No newline at end of file diff --git a/roles/common/tasks/install-fedora-essentials.yml b/roles/common/tasks/install-fedora-essentials.yml @@ -0,0 +1,6 @@ +--- +- name: Install essentials + become: yes + package: name={{item}} state=present + with_items: + - python3-psutil+ \ No newline at end of file diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- include: install-essentials.yml +- include: install-fedora-essentials.yml + when: ansible_distribution == 'Fedora'+ \ No newline at end of file diff --git a/roles/desktop/files/rpmfusion-free-updates-testing.repo b/roles/desktop/files/rpmfusion-free-updates-testing.repo @@ -0,0 +1,31 @@ +[rpmfusion-free-updates-testing] +name=RPM Fusion for Fedora $releasever - Free - Test Updates +#baseurl=http://download1.rpmfusion.org/free/fedora/updates/testing/$releasever/$basearch/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-updates-testing-$releasever&arch=$basearch +enabled=0 +enabled_metadata=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + +[rpmfusion-free-updates-testing-debuginfo] +name=RPM Fusion for Fedora $releasever - Free - Test Updates Debug +#baseurl=http://download1.rpmfusion.org/free/fedora/updates/testing/$releasever/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-updates-testing-debug-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + +[rpmfusion-free-updates-testing-source] +name=RPM Fusion for Fedora $releasever - Free - Test Updates Source +#baseurl=http://download1.rpmfusion.org/free/fedora/updates/testing/$releasever/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-updates-testing-source-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + diff --git a/roles/desktop/files/rpmfusion-free-updates.repo b/roles/desktop/files/rpmfusion-free-updates.repo @@ -0,0 +1,31 @@ +[rpmfusion-free-updates] +name=RPM Fusion for Fedora $releasever - Free - Updates +#baseurl=http://download1.rpmfusion.org/free/fedora/updates/$releasever/$basearch/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-updates-released-$releasever&arch=$basearch +enabled=1 +enabled_metadata=1 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + +[rpmfusion-free-updates-debuginfo] +name=RPM Fusion for Fedora $releasever - Free - Updates Debug +#baseurl=http://download1.rpmfusion.org/free/fedora/updates/$releasever/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-updates-released-debug-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + +[rpmfusion-free-updates-source] +name=RPM Fusion for Fedora $releasever - Free - Updates Source +#baseurl=http://download1.rpmfusion.org/free/fedora/updates/$releasever/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-updates-released-source-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + diff --git a/roles/desktop/files/rpmfusion-free.repo b/roles/desktop/files/rpmfusion-free.repo @@ -0,0 +1,33 @@ +[rpmfusion-free] +name=RPM Fusion for Fedora $releasever - Free +#baseurl=http://download1.rpmfusion.org/free/fedora/releases/$releasever/Everything/$basearch/os/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-$releasever&arch=$basearch +enabled=1 +metadata_expire=14d +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + +[rpmfusion-free-debuginfo] +name=RPM Fusion for Fedora $releasever - Free - Debug +#baseurl=http://download1.rpmfusion.org/free/fedora/releases/$releasever/Everything/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-debug-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + +[rpmfusion-free-source] +name=RPM Fusion for Fedora $releasever - Free - Source +#baseurl=http://download1.rpmfusion.org/free/fedora/releases/$releasever/Everything/source/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=free-fedora-source-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever + diff --git a/roles/desktop/files/rpmfusion-nonfree-nvidia-driver.repo b/roles/desktop/files/rpmfusion-nonfree-nvidia-driver.repo @@ -0,0 +1,30 @@ +[rpmfusion-nonfree-nvidia-driver] +name=RPM Fusion for Fedora $releasever - Nonfree - NVIDIA Driver +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/nvidia-driver/$releasever/$basearch/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-nvidia-driver-$releasever&arch=$basearch +enabled=0 +enabled_metadata=1 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///usr/share/distribution-gpg-keys/rpmfusion/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-nvidia-driver-debuginfo] +name=RPM Fusion for Fedora $releasever - Nonfree - NVIDIA Driver Debug +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/nvidia-driver/$releasever/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-nvidia-driver-debug-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///usr/share/distribution-gpg-keys/rpmfusion/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-nvidia-driver-source] +name=RPM Fusion for Fedora $releasever - Nonfree - NVIDIA Driver Source +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/nvidia-driver/$releasever/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-nvidia-driver-source-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///usr/share/distribution-gpg-keys/rpmfusion/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever diff --git a/roles/desktop/files/rpmfusion-nonfree-steam.repo b/roles/desktop/files/rpmfusion-nonfree-steam.repo @@ -0,0 +1,30 @@ +[rpmfusion-nonfree-steam] +name=RPM Fusion for Fedora $releasever - Nonfree - Steam +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/steam/$releasever/$basearch/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-steam-$releasever&arch=$basearch +enabled=0 +enabled_metadata=1 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///usr/share/distribution-gpg-keys/rpmfusion/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-steam-debuginfo] +name=RPM Fusion for Fedora $releasever - Nonfree - Steam Debug +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/steam/$releasever/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-steam-debug-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///usr/share/distribution-gpg-keys/rpmfusion/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-steam-source] +name=RPM Fusion for Fedora $releasever - Nonfree - Steam Source +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/steam/$releasever/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-steam-source-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///usr/share/distribution-gpg-keys/rpmfusion/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever diff --git a/roles/desktop/files/rpmfusion-nonfree-updates-testing.repo b/roles/desktop/files/rpmfusion-nonfree-updates-testing.repo @@ -0,0 +1,31 @@ +[rpmfusion-nonfree-updates-testing] +name=RPM Fusion for Fedora $releasever - Nonfree - Test Updates +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/updates/testing/$releasever/$basearch/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-updates-testing-$releasever&arch=$basearch +enabled=0 +enabled_metadata=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-updates-testing-debuginfo] +name=RPM Fusion for Fedora $releasever - Nonfree - Test Updates Debug +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/updates/testing/$releasever/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-updates-testing-debug-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-updates-testing-source] +name=RPM Fusion for Fedora $releasever - Nonfree - Test Updates Source +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/updates/testing/$releasever/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-updates-testing-source-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + diff --git a/roles/desktop/files/rpmfusion-nonfree-updates.repo b/roles/desktop/files/rpmfusion-nonfree-updates.repo @@ -0,0 +1,31 @@ +[rpmfusion-nonfree-updates] +name=RPM Fusion for Fedora $releasever - Nonfree - Updates +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/updates/$releasever/$basearch/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-updates-released-$releasever&arch=$basearch +enabled=1 +enabled_metadata=1 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-updates-debuginfo] +name=RPM Fusion for Fedora $releasever - Nonfree - Updates Debug +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/updates/$releasever/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-updates-released-debug-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-updates-source] +name=RPM Fusion for Fedora $releasever - Nonfree - Updates Source +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/updates/$releasever/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-updates-released-source-$releasever&arch=$basearch +enabled=0 +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + diff --git a/roles/desktop/files/rpmfusion-nonfree.repo b/roles/desktop/files/rpmfusion-nonfree.repo @@ -0,0 +1,34 @@ +[rpmfusion-nonfree] +name=RPM Fusion for Fedora $releasever - Nonfree +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/releases/$releasever/Everything/$basearch/os/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-$releasever&arch=$basearch +enabled=1 +enabled_metadata=1 +metadata_expire=14d +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-debuginfo] +name=RPM Fusion for Fedora $releasever - Nonfree - Debug +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/releases/$releasever/Everything/$basearch/debug/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-debug-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + +[rpmfusion-nonfree-source] +name=RPM Fusion for Fedora $releasever - Nonfree - Source +#baseurl=http://download1.rpmfusion.org/nonfree/fedora/releases/$releasever/Everything/source/SRPMS/ +metalink=https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-source-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +type=rpm-md +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever + diff --git a/roles/desktop/tasks/gnome.yml b/roles/desktop/tasks/gnome.yml @@ -0,0 +1,19 @@ +--- +- name: Install dconf-editor + become: yes + package: name=dconf-editor state=present +- name: Enable Night Light + dconf: + key: "/org/gnome/settings-daemon/plugins/color/night-light-enabled" + value: "true" + state: present +- name: Enable Night Light + dconf: + key: "/org/gnome/settings-daemon/plugins/color/night-light-schedule-automatic" + value: "true" + state: present +- name: Enable Night Light + dconf: + key: "/org/gnome/settings-daemon/plugins/color/night-light-temperature" + value: "5000" + state: present+ \ No newline at end of file diff --git a/roles/desktop/tasks/main.yml b/roles/desktop/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- include: gnome.yml + when: ansible_distribution == 'Fedora' +- include: media.yml+ \ No newline at end of file diff --git a/roles/desktop/tasks/media.yml b/roles/desktop/tasks/media.yml @@ -0,0 +1,23 @@ +--- +- name: add rpmfusion repos + copy: + src: "{{ item }}" + dest: "/etc/yum.repos.d/{{ item }}" + owner: root + group: root + mode: 0644 + with_items: + - rpmfusion-free.repo + - rpmfusion-free-updates.repo + - rpmfusion-free-updates-testing.repo + - rpmfusion-nonfree-nvidia-driver.repo + - rpmfusion-nonfree.repo + - rpmfusion-nonfree-steam.repo + - rpmfusion-nonfree-updates.repo + - rpmfusion-nonfree-updates-testing.repo + when: ansible_distribution == 'Fedora' +- name: install media + become: yes + package: name={{item}} state=present + with_items: + - mpv+ \ No newline at end of file diff --git a/roles/laptop/tasks/common.yml b/roles/laptop/tasks/common.yml @@ -0,0 +1,12 @@ +--- +- name: Common laptop utilities + become: yes + package: name={{item}} state=present + with_items: + - acpi + - powertop +- name: enable powertop + systemd: + name: powertop.service + state: started + enabled: yes+ \ No newline at end of file diff --git a/roles/laptop/tasks/main.yml b/roles/laptop/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- include: common.yml +- include: thinkpad.yml + when: ansible_product_version == 'ThinkPad X220' +- name: just force systemd to reread configs (2.4 and above) + systemd: + daemon_reload: yes+ \ No newline at end of file diff --git a/roles/laptop/tasks/thinkpad.yml b/roles/laptop/tasks/thinkpad.yml @@ -0,0 +1,17 @@ +--- +- name: ThinkPad X220 laptop utilities + become: yes + package: name={{item}} state=present + with_items: + - tlp + - tlp-rdw +- name: enable tlp + systemd: + name: tlp.service + state: started + enabled: yes +- name: enable tlp-sleep + systemd: + name: tlp.service + state: started + enabled: yes+ \ No newline at end of file