ansible: v2.14.1
ansible-lint: v6.10.0
python: v3.10.9
brew install ansible
pip3 install ansible-lint # Optional
brew install hudochenkov/sshpass/sshpass
# Check
ansible --version
ansible-lint --version # Optional
- Check syntax (Optional)
ansible-lint <your playbook>
ansible-galaxy collection install community.docker
# Check
ansible-galaxy collection list
- Customize your data.
- Modify
hosts
with your hostname and user. - Modify
ansible.cfg
with yourprivate_key_file
path. - Modify
./infra/config/config.s3.tfbackend
with your config values. - Run the following command to check connection.
# `server` indicate `[server]` in `hosts`.
# You can use `all` instead of `server` to ping all the inventory in `hosts`.
ansible server -m ping
-
Setup Security group and IAM to your EC2 instance.
-
Run playbook
ansible-playbook deploy_s3bucket.yml
# If your file is encrypted.
ansible-playbook deploy_s3bucket.yml -i hosts --ask-vault-pass
-
Setup Security group and IAM to your EC2 instance.
-
Run playbook
ansible-playbook deploy_docker_jenkins.yml
# If your file is encrypted.
ansible-playbook deploy_docker_jenkins.yml -i hosts --ask-vault-pass
- Open your browser and enter your EC2's Public IPv4 DNS with port 8080 (http).
docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v $HOME:/var/jenkins_home jenkins/jenkins:lts-jdk11
-
Access http://localhost:8080 and authorized with admin password. Default path of password is
/var/jenkins_home/secrets/initialAdminPassword
. -
Install Ansible with available version
# Enter container with root user.
docker exec -it --user root myjenkins bash
# Install Ansible
apt update
apt install ansible
# Check version
ansible --version
- Run
which ansible
to show the path. - Navigate to
Dashboard > Manage Jenkins > Global Tool Configuration
and setup Ansible.
- After building the pipeline, Jenkins will load the Jenkinsfile and update the content.