/ linux

Setting up Fedora 28 using Ansible

So I have this shiny new Dell XPS 13 9370. Unfortunately, it came with Windows installed instead of Linux. Dell makes a Linux version of this ultrabook that ships with Ubuntu pre-installed. The fact that they do that is really great, in part because we can expect the hardware to play nice with Linux.

Step One: Download and Install Fedora

I'm going to install Fedora 28 on mine because it looks like a great new release from a very solid distribution.

One nice thing that Fedora gives us, when downloading from a Windows machine, is this handy Fedora Media Writer that does all the dirty work of downloading the image, checking it, and writing everything to your USB drive. Go grab it and do the same:


I'm going to skip over the base installation because the steps are very specific to this particular machine. Perhaps I'll go over the XPS 13 quirks elsewhere. Now I have a fresh install of Fedora with no modifications beyond having created a user and connected to wifi. Now let's build a developer system!

Step Two: Install Ansible

We need to manually install ansible because we're not using an external ansible control machine to orchestrate this. It would be cool to do it that way one day, but for now I am happy enough going through a few manual steps to get things going locally:=

sudo dnf install ansible

(This will install a bunch of python libraries as well.)

Step Three: Getting Started with Ansible

Create a directory for this all to go in:

mkdir ansible-develop

Next make two basic configuration files, ansible.cfg and hosts:

contents of ~/ansible-develop/hosts:

localhost    ansible_connection=local

contents of ~/ansible-develop/ansible.cfg:

inventory       = hosts
ask_become_pass = True

Now we can make our first ansible playbook. Let's call it packages.yml:

contents of ~/ansible-develop/packages.yml:

- name: Update and Install packages
  hosts: localhost
  become: True
    - name: upgrade all packages
        name: "*"
        state: latest
    - name: install vim
        name: vim
        state: present

Got it? Let's see if it works. Run this command to execute our packages playbook:

cd ~/ansible-develop
ansible-playbook -K packages.yml

(Be sure to run the ansible-playbook commands that follow from your new directory, because by default ansible will look for an ansible.cfg config file in whatever current directory you are running ansible commands within.)

Your shell should prompt you for your sudo password and then go ahead and run the updates and install vim.

Assuming that worked, we can now start to build up our ansible arsenal.

Step Four: More Packages!

Re-open packages.yml and add more packages that you're going to want. You don't have to copy my list if you have a clear idea of what you are going to use. Make sure any package listed can be found by Fedora's dnf tool. Test if unsure:

dnf search ack

contents of ~/ansible-develop/packages.yml:

- name: Install development packages
  hosts: localhost
  become: True
    - name: upgrade all packages
        name: "*"
        state: latest

    - name: install development packages
      package: name={{ item }}
        - ack
        - autoconf
        - automake
        - bison
        - bzip2
        - curl
        - emacs
        - gcc-c++
        - git
        - gmp-devel
        - htop
        - libbsd-devel
        - libedit-devel
        - libevent-devel
        - libffi-devel
        - libtool
        - libselinux-python
        - libxml2-devel
        - libyaml-devel
        - llvm-static
        - make
        - mariadb-devel
        - openssl-devel
        - patch
        - pgadmin3
        - postgresql-devel
        - readline-devel
        - redhat-rpm-config
        - ruby-devel
        - svn
        - tmux
        - tree
        - util-linux-user
        - vim
        - xclip
        - zlib-devel

Let's do this:

ansible-playbook -K packages.yml

You'll notice that anything already installed is not re-installed. Thus, the ansible-playbook is idempotent, meaning it will have the same end result no matter how many times you run it. It is safe to run and re-run the playbook often. Now you can keep adding to this package list whenever you discover new packages that you require in your development environment. You can easily port this playbook to another machine, or a VM or fresh installation and quickly re-install everything you need.

Later we will look at setting up some enhancements to the shell and text editors.

Benjamin Rosas

Benjamin Rosas

I am a constantly curious programmer with a background in science. I enjoy open-source software, programming languages, web development and server administration, along with music, travel and snark.

Read More
Setting up Fedora 28 using Ansible
Share this