Skip to content

Commit

Permalink
Fix install automation
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Nov 7, 2018
1 parent 66bd9fb commit 7cc6a91
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 16 deletions.
57 changes: 52 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TAG = latest
# Ansible variables
VERBOSE=
PROFILE=cytopia-t470p
ARG=

.PHONY: help build-docker test-docker-full test-docker-random test-docker-single itest-docker-full itest-docker-random itest-docker-single

Expand Down Expand Up @@ -90,8 +91,11 @@ test-vagrant:
# Deploy Targets
#--------------------------------------------------------------------------------------------------

# (Step 1/3) Ensure required software is present
# (Step 1/4) [requires root] Ensure required software is present
deploy-init:
ifneq ($(USER),root)
$(error Target 'deploy-init' must be run as root or with sudo)
endif
DEBIAN_FRONTEND=noninteractive apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -qq -q --no-install-recommends --no-install-suggests \
python-apt \
Expand All @@ -102,12 +106,55 @@ deploy-init:
pip install wheel
pip install ansible

# (Step 2/3) Add new Debian sources and dist-upgrade your system
deploy-dist-upgrade:
# (Step 2/4) Add new Debian sources
deploy-apt-sources:
ifeq ($(USER),root)
$(error Target 'deploy-apt-sources' must be run as normal user without sudo)
endif
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff -t bootstrap-system --ask-become-pass

# (Step 3/4) [requires root] Adist-upgrade your system
deploy-dist-upgrade:
ifneq ($(USER),root)
$(error Target 'deploy-dist-upgrade' must be run as root or with sudo)
endif
DEBIAN_FRONTEND=noninteractive apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -qq -y

# (Step 3/3) Deploy your system
# (Step 4/4) Deploy your system
deploy-tools:
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --ask-become-pass
ifeq ($(USER),root)
$(error Target 'deploy-tools' must be run as normal user without sudo)
endif
ifndef ROLE
ifndef IGNORE
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --ask-become-pass $(ARG)
else
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --ask-become-pass $(ARG) --skip-tags=$(IGNORE)
endif
else
ifndef IGNORE
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --ask-become-pass $(ARG) -t $(ROLE)
else
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --ask-become-pass $(ARG) -t $(ROLE) --skip-tags=$(IGNORE)
endif
endif

# Checkmode to test against currently installed tools
diff-tools:
ifeq ($(USER),root)
$(error Target 'diff-tools' must be run as normal user without sudo)
endif
ifndef ROLE
ifndef IGNORE
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --check --ask-become-pass $(ARG)
else
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --check --ask-become-pass $(ARG) --skip-tags=$(IGNORE)
endif
else
ifndef IGNORE
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --check --ask-become-pass $(ARG) -t $(ROLE)
else
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --check --ask-become-pass $(ARG) -t $(ROLE) --skip-tags=$(IGNORE)
endif
endif
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,25 @@ cd ansible-debian-testing
# 2. Add your profile 'bob' (See 'Create custom profiles' section of this README)

# 3. Provision your system (with profile 'bob')
# Note when to use sudo and when not
sudo make deploy-init
sudo make deploy-dist-upgrade PROFILE=bob
sudo make deploy-tools PROFILE=bob
make deploy-apt-sources PROFILE=bob
sudo make deploy-dist-upgrade
make deploy-tools PROFILE=bob
```

#### Dry-run the tools installation

```bash

# Dry-run everything for profile 'generic-all'
ansible-playbook -i inventory playbook.yml --diff --limit generic-all --ask-become-pass --check
make diff-tools PROFILE=generic-all

# Dry-run everything for profile 'generic-all' without role 'systemd'
make diff-tools PROFILE=generic-all IGNORE=systemd

# Dry-run a specific role 'i3-gaps'
ansible-playbook -i inventory playbook.yml --diff --limit generic-all --ask-become-pass -t i3-gaps
# Dry-run a specific role 'i3-gaps'
make diff-tools PROFILE=generic-all ROLE=i3-gaps
```


Expand Down
5 changes: 3 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Vagrant.configure("2") do |config|
sudo apt-get update -qq
sudo apt-get install --no-install-recommends --no-install-suggests -y make
sudo make deploy-init
sudo make deploy-dist-upgrade PROFILE=#{ENV['PROFILE']}
sudo make deploy-tools PROFILE=#{ENV['PROFILE']}
make deploy-apt-sources PROFILE=#{ENV['PROFILE']}
sudo make deploy-dist-upgrade
make deploy-tools PROFILE=#{ENV['PROFILE']}
SHELL
end
11 changes: 7 additions & 4 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ cd ansible-debian-testing
### Deploy
###

# (Step 1/3) Ensure required software is present
# (Step 1/4) Ensure required software is present
sudo make deploy-init

# (Step 2/3) Add new Debian sources and dist-upgrade your system
sudo make deploy-dist-upgrade PROFILE=${PROFILE}
# (Step 2/4) Add new Debian sources
make deploy-apt-sources PROFILE=${PROFILE}

# (Step 3/4) dist-upgrade your system
sudo make deploy-dist-upgrade

# (Step 3/3) Deploy your system
sudo make deploy-tools PROFILE=${PROFILE}
make deploy-tools PROFILE=${PROFILE}

0 comments on commit 7cc6a91

Please sign in to comment.