Skip to content

Commit

Permalink
Merge pull request #213 from lemberg/feature/53-expose-draft
Browse files Browse the repository at this point in the history
Expose draft environment via environment variable DRAFT_ENVIRONMENT
  • Loading branch information
T2L committed Aug 18, 2020
2 parents 53d4d18 + 15ea903 commit d8e817c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:

install:
- composer install --no-interaction --no-progress --no-suggest --prefer-dist --optimize-autoloader --no-dev
- pip install ansible==2.9.* ansible-lint docker flake8 molecule==3.*
- pip install ansible~=2.9 ansible-lint docker yamllint molecule~=3.0,!=3.0.7

script:
- molecule test
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Fixes:

- [GH-53](https://github.com/lemberg/draft-environment/issues/53) - Expose draft environment via environment variable `DRAFT_ENVIRONMENT`
- [GH-214](https://github.com/lemberg/draft-environment/issues/214) - Address newly introduced issue(s) with file permissions. See https://github.com/ansible/ansible/pull/70221 and https://github.com/ansible/ansible/issues/71200

## Draft Environment 3.1.1, 2020-08-12
Expand Down
3 changes: 2 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ lint: |
set -e
yamllint --config-data "{ignore: vendor/}" .
ansible-lint
flake8
platforms:
- name: draft
image: "geerlingguy/docker-${MOLECULE_PLATFORM}-ansible:latest"
Expand All @@ -24,3 +23,5 @@ provisioner:
remote_tmp: /tmp/ansible
ssh_connection:
pipelining: true
verifier:
name: ansible
10 changes: 10 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

- name: Verify
hosts: all
tasks:
- name: Verify that Draft exposes itself via environment variable
assert:
that:
- "{{ lookup('env', 'DRAFT_ENVIRONMENT') }}"
quiet: true
9 changes: 8 additions & 1 deletion provisioning/roles/apache2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,20 @@
with_items:
- '{{ vagrant.destination_directory }}/{{ apache2_document_root }}'

- name: Get /etc/apache2/mods-available/dir.conf permissions
stat:
path: /etc/apache2/mods-available/dir.conf
get_checksum: no
get_mime: no
register: dir_conf_stat

# Configure web server.
- name: Set correct DirectoryIndex
lineinfile:
dest: /etc/apache2/mods-available/dir.conf
regexp: "DirectoryIndex"
line: "DirectoryIndex index.php index.html"
mode: preserve
mode: '{{ dir_conf_stat.stat.mode }}'

# Disable default virtual host created on Ubuntu/Debian.
- name: Disable default virtual host.
Expand Down
33 changes: 30 additions & 3 deletions provisioning/roles/draft/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,33 @@
dest: /etc/profile.d/vendor_path.sh
mode: 0644

- name: Get /etc/environment permissions
stat:
path: /etc/environment
get_checksum: no
get_mime: no
register: etc_environment_stat

- name: Expose draft environment via environment variable
lineinfile:
path: /etc/environment
line: DRAFT_ENVIRONMENT=true
mode: '{{ etc_environment_stat.stat.mode }}'

- name: Get ~/.bashrc permissions
stat:
path: ~/.bashrc
get_checksum: no
get_mime: no
register: bashrc_stat

- name: Use Vagrant base directory as a default SSH directory
become: true
become_user: vagrant
lineinfile:
path: ~/.bashrc
line: cd {{ ssh_default_directory }}
mode: preserve
mode: '{{ bashrc_stat.stat.mode }}'

- name: Ensure locale exists
locale_gen:
Expand All @@ -78,12 +98,19 @@
command: update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
when: ansible_env.LC_ALL is not defined

- name: Get /etc/ssh/sshd_config permissions
stat:
path: /etc/ssh/sshd_config
get_checksum: no
get_mime: no
register: sshd_config_stat

- name: Ensure that PasswordAuthentication is enabled
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^PasswordAuthentication '
line: 'PasswordAuthentication yes'
mode: preserve
mode: '{{ sshd_config_stat.stat.mode }}'
notify:
- Restart SSH server

Expand All @@ -92,6 +119,6 @@
path: /etc/ssh/sshd_config
regexp: '^ChallengeResponseAuthentication '
line: 'ChallengeResponseAuthentication yes'
mode: preserve
mode: '{{ sshd_config_stat.stat.mode }}'
notify:
- Restart SSH server

0 comments on commit d8e817c

Please sign in to comment.