-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ansible
provisioner to Linux builds (#117)
re: #54 - Adds the`ansible` provisioner for preparation of **Linux** builds. - Updates guest operating system. - Adds additional packages. - Adds CA certificate to trust authority. - Removes use of the `file` provisioner for certificates. - Removes Ansible steps from scripts (more to follow). - Updates the README.md. - Requires Ansible 2.9 or higher on the system running Packer. - Cleanup of `build.sh`.
- Loading branch information
Ryan Johnson
authored
Oct 10, 2021
1 parent
14e85e3
commit d7e7e87
Showing
29 changed files
with
497 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[defaults] | ||
command_warnings = false | ||
display_skipped_hosts = false | ||
ansible_python_interpreter = /usr/bin/python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
- hosts: all | ||
debugger: never | ||
gather_facts: yes | ||
become: yes | ||
become_method: sudo | ||
roles: | ||
- base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
# Defaults for base. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
- name: Ubuntu - Updating the certificate authority trust. | ||
shell: update-ca-certificates | ||
|
||
- name: RedHat - Updating the certificate authority trust. | ||
shell: update-ca-trust extract | ||
|
||
- name: VMware Photon OS - Updating the certificate authority trust. | ||
shell: rehash_ca_certificates.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
- name: Prepare {{ ansible_facts['distribution'] }} distribution. | ||
include_tasks: "{{ ansible_facts['distribution'] | lower }}.yml" | ||
when: ansible_facts['distribution'] == 'Ubuntu' | ||
|
||
- name: Prepare {{ ansible_facts['distribution'] }} distribution. | ||
### Generalized since Rocky Linux and AlmaLinux do not report `os_family` as `RedHat` in some versions of Ansible. | ||
include_tasks: "redhat.yml" | ||
when: ansible_facts['distribution'] in ['RedHat', 'CentOS', 'Rocky', 'AlmaLinux'] | ||
|
||
- name: Prepare {{ ansible_facts['os_family'] }} distribution. | ||
include_tasks: "{{ ansible_facts['lsb']['codename'] | lower }}.yml" | ||
when: ansible_facts['os_family'] == 'VMware Photon OS' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." | ||
command: "{{item}}" | ||
with_items: | ||
### ----------------------------------------------- ### | ||
### Required due to a bug in VMware Photon OS 4.0. ### | ||
- tdnf -y remove minimal | ||
- rpm -e --noscripts systemd-udev-247.3-1.ph4 | ||
### ----------------------------------------------- ### | ||
- tdnf clean all | ||
- tdnf makecache | ||
- tdnf -y update | ||
args: | ||
warn: false | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." | ||
command: | | ||
tdnf -y install \ | ||
minimal \ | ||
logrotate \ | ||
wget \ | ||
git \ | ||
unzip \ | ||
tar \ | ||
jq \ | ||
parted \ | ||
openssl-c_rehash | ||
args: | ||
warn: false | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Importing Certificate Authority certificates." | ||
copy: | ||
src: root-ca.crt | ||
dest: /etc/ssl/certs/root-ca.pem | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: "{{ ansible_facts['distribution'] }} - Updating the certificate authority trust." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
### Red Hat Enterprise Linux | ||
|
||
- name: Red Hat Subscription Manager Status | ||
shell: subscription-manager refresh | ||
when: ansible_facts['distribution'] == 'RedHat' | ||
|
||
### Red Hat Enterprise Linux >= 8 and Derivative Distributions | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." | ||
dnf: | ||
name: "*" | ||
state: latest | ||
update_cache: yes | ||
when: ansible_facts['distribution_major_version'] >= "8" | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." | ||
dnf: | ||
name: | ||
- curl | ||
- wget | ||
- git | ||
- vim | ||
- net-tools | ||
- unzip | ||
- ca-certificates | ||
state: latest | ||
when: ansible_facts['distribution_major_version'] >= "8" | ||
|
||
### Red Hat Enterprise Linux <= 7 and Derivative Distributions | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." | ||
yum: | ||
name: "*" | ||
state: latest | ||
update_cache: yes | ||
when: | ||
- ansible_facts['distribution_major_version'] <= "7" | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." | ||
yum: | ||
name: | ||
- curl | ||
- wget | ||
- git | ||
- vim | ||
- net-tools | ||
- unzip | ||
- ca-certificates | ||
state: latest | ||
when: ansible_facts['distribution_major_version'] <= "7" | ||
|
||
### Red Hat Enterprise Linux and Derivative Distributions | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Importing Certificate Authority certificates." | ||
copy: | ||
src: root-ca.crt | ||
dest: /etc/pki/ca-trust/source/anchors/root-ca.crt | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: RedHat - Updating the certificate authority trust. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Updating the guest operating system." | ||
apt: | ||
name: "*" | ||
state: latest | ||
update_cache: yes | ||
force_apt_get: true | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Installing additional packages." | ||
apt: | ||
name: | ||
- bash-completion | ||
- curl | ||
- wget | ||
- git | ||
- net-tools | ||
- unzip | ||
- ca-certificates | ||
state: latest | ||
|
||
- name: "{{ ansible_facts['distribution'] }} - Importing Certificate Authority certificates." | ||
copy: | ||
src: root-ca.crt | ||
dest: /usr/local/share/ca-certificates/ | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: "{{ ansible_facts['distribution'] }} - Updating the certificate authority trust." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
# vars for base |
Oops, something went wrong.