Search code examples
ubuntusalt-project

How to properly install Ubuntu using SaltStack?


I was till last month able to install salt machine without any problem, from then I have not changed anything (this is important).

I'm using Ubuntu server 14.04.

I will write here step by step how I installed every new machine using salt stack (and I have installed many machines almost every day because of some kid of testing).

Steps:

curl -L https://bootstrap.saltstack.com -o bootstrap_salt.sh
sudo sh bootstrap_salt.sh
salt-call --local state.highstate -l debug

Suddenly this error started to showing on every attempt to install new machine, this is one of many errors related to user and groups, but it is first on the list. enter image description here

Something has changed so I have tried to download old bootstrap_salt.sh file and to call old version of salt, for example:

sudo sh bootstrap_salt.sh -P git v2015.8.7

But without any changes, error is still showing up.

Can somebody give me instructions which are working?

Thank you


Solution

  • It looks like the 'demo' user is not being created before the www-data state is being run.

    Salt States are not necessarily run in order, so when this state runs before the demo user exists, it will fail. The frustrating thing is that sometimes this state will be applied after the user is created and it will succeed. That's probably why this error seemed to come out of nowhere.

    To make sure www-data runs after the user is created, it should require the state that creates the 'demo' user, like so:

    www-data:
       group.present:
        - members:
          - demo
        - require:
          - user: demo