Permalink
![Ansible make install windows 7 Ansible make install windows 7](/uploads/1/2/5/6/125662262/786894959.png)
Mar 26, 2018 - Learn how to make Ansible automatically apply configuration. Normally the apt module allows us to install packages, but we can also tell it to. Readers that use virtualenv can also install Ansible under virtualenv, though we’d recommend to not worry about it and just install Ansible globally. Do not use easy_install to install Ansible directly.
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
geerlingguyResolve ansible-lint problems.3470557Jan 4, 2019
2 contributors
--- |
- name: Ensure dependencies for building from source are installed (RedHat). |
package: |
name: |
- autoconf |
- automake |
- libtool |
- bison |
- make |
- curl-devel |
- recode-devel |
- aspell-devel |
- libxml2-devel |
- pkgconfig |
- libmcrypt-devel |
- t1lib-devel |
- libXpm-devel |
- libpng-devel |
- libjpeg-turbo-devel |
- bzip2-devel |
- openssl-devel |
- freetype-devel |
- libicu-devel |
- mariadb-devel |
- gmp-devel |
state: present |
when: ansible_os_family 'RedHat' |
- name: Update apt cache (Debian). |
apt: update_cache=yes cache_valid_time=86400 |
when: ansible_os_family 'Debian' |
- name: Ensure dependencies for building from source are installed (Debian). |
apt: |
name: |
- build-essential |
- autoconf |
- automake |
- libtool |
- bison |
- pkg-config |
- re2c |
- libxml2-dev |
- libcurl4-openssl-dev |
- libbz2-dev |
- libjpeg-dev |
- libpng-dev |
- libxpm-dev |
- libfreetype6-dev |
- libgmp3-dev |
- libmcrypt-dev |
- libmysqlclient-dev |
- libpspell-dev |
- librecode-dev |
- libssl-dev |
state: present |
when: ansible_os_family 'Debian' |
- name: Define php_fpm_daemon (if not defined already). |
set_fact: |
php_fpm_daemon: 'php-fpm' |
when: php_fpm_daemon is not defined |
- name: Check if gmp.h is already in a location accessible to gcc. |
stat: path=/usr/include/gmp.h |
register: gmp_file |
- name: Ensure gmp.h is symlinked into a location accessible to gcc. |
file: |
src: '{{ php_source_install_gmp_path }}' |
dest: /usr/include/gmp.h |
state: link |
when: not gmp_file.stat.exists |
- name: Check if PHP is installed. |
command: which php |
changed_when: false |
failed_when: false |
register: php_installed |
- name: Clone the PHP repository. |
git: |
repo: '{{ php_source_repo }}' |
dest: '{{ php_source_clone_dir }}' |
version: '{{ php_source_version }}' |
accept_hostkey: true |
depth: '{{ php_source_clone_depth }}' |
when: php_installed.rc != 0 |
- name: Ensure PHP installation path exists. |
file: |
path: '{{ php_source_install_path }}' |
state: directory |
mode: 0755 |
when: php_installed.rc != 0 |
- name: Build configure script. |
command: > |
./buildconf --force |
chdir={{ php_source_clone_dir }} |
when: php_installed.rc != 0 |
- name: Run configure script. |
command: > |
{{ php_source_configure_command }} |
chdir={{ php_source_clone_dir }} |
when: php_installed.rc != 0 |
- name: Make and install PHP. |
command: > |
{{ item }} |
chdir={{ php_source_clone_dir }} |
with_items: |
- '{{ php_source_make_command }}' |
- make install |
when: php_installed.rc != 0 |
- name: Ensure php executable is symlinked into a standard path. |
file: |
src: '{{ php_source_install_path }}/bin/php' |
dest: /usr/bin/php |
state: link |
# PHP FPM configuration. |
- name: Ensure php-fpm executable is symlinked into a standard path. |
file: |
src: '{{ php_source_install_path }}/sbin/php-fpm' |
dest: '/usr/sbin/{{ php_fpm_daemon }}' |
state: link |
when: ''--enable-fpm' in php_source_configure_command' |
- name: Ensure php-fpm init script is installed. |
template: |
src: fpm-init.j2 |
dest: '/etc/init.d/{{ php_fpm_daemon }}' |
mode: 0755 |
when: ''--enable-fpm' in php_source_configure_command' |
notify: restart php-fpm |
- name: Ensure php-fpm config directory exists. |
file: |
path: '{{ php_fpm_conf_path }}' |
state: directory |
when: ''--enable-fpm' in php_source_configure_command' |
- name: Ensure php-fpm config file is installed. |
template: |
src: php-fpm.conf.j2 |
dest: '{{ php_fpm_conf_path }}/php-fpm.conf' |
mode: 0644 |
when: ''--enable-fpm' in php_source_configure_command' |
notify: restart php-fpm |
Copy lines Copy permalink
Ansible is yet another tool for managing a large number of servers. With Ansible playbooks, you can create incredibly flexible, automated tasks to run on your data center servers, all from a single point of entry. Even better, you can create Ansible playbooks and run them from the likes of the user-friendly web-based GUI, Rundeck.
Data Center Must-Reads
Once you have Ansible up and running, you can then attach nodes and start creating your playbooks. But first, you have to install Ansible.
I want to walk you through the steps of installing the official Ansible release on Ubuntu Server 18.04. We'll then export the Ansible server SSH keys to a single client node (to demonstrate how nodes are associated with the server), and configure that node in Ansible.
SEE: Data center automation research report 2018: Despite growth in data, automation adoption remains slow (Tech Pro Research)
What you need
You will need two Ubuntu Server 18.04 installations, as well as user accounts (on both) with sudo privileges. That's all.
![Ansible make install windows 7 Ansible make install windows 7](/uploads/1/2/5/6/125662262/786894959.png)
Update/upgrade
Before we install Ansible, make sure that your server is updated and upgraded. Do note, should your kernel be upgraded, you'll need to reboot the server. Because of this, make sure to run the update/upgrade at a time when a reboot is possible (unless you have live patching installed, at which point you can run the task any time). To update and upgrade, log into the server to host Ansible and issue the following commands:
Once that process completes, reboot the server (if necessary). You're now ready to install.
Installing Ansible
Next, install Ansible. Here are the steps to make that happen:
- Log into the Ubuntu Server that will host Ansible
- Install the necessary repository with the command sudo apt-add-repository ppa:ansible/ansible.
- Update apt with the command sudo apt-get update.
- Install Ansible with the command sudo apt-get install ansible -y.
Because Ansible requires a Python interpreter (in order to run its modules), we need to install Python as well. For that, issue the command:
Note: You may find Python already installed.
At this point, Ansible is installed and ready to go.
Configure SSH access to the server
Next, we need to make it possible for our node to access the Ansible server. We do this via Secure Shell (SSH). Copy the server's SSH public key to the node. If your server doesn't have a key yet, generate one with the command:
You will be asked for a file name (keep the default) and to create/verify a passphrase for the key (Figure A).
Figure A
Display the contents of the public SSH key with the command:
Here's what you do with the output of that command:
- Copy the text from the key.
- Log into your node server.
- Issue the command sudo -s.
- Open the authorized_keys file with the command sudo nano ~/.ssh/authorized_keys.
- Paste the contents of the server key at the bottom of this file.
- Save and close the file.
If you want to simplify this process, issue the command (from the Ansible server):
Where NODE_IP is the IP Address of the node to be added.
To test the newly added key, go back to your Ansible server and SSH to the node machine. Instead of being prompted for the user's password, you should be prompted for the SSH key passphrase (Figure B).
Figure B
Complete this for all of the nodes you want connected to Ansible.
Setting up our node
Next, make sure Ansible knows the location of our node. Issue the command:
In that file, create a new group for your nodes (in our case, we've only connected one node) and associate the IP addresses like so:
Where group_name is the name of the group to be created, ALIAS is an alias for the node, and NODE_IP is the IP address of your node. If you have more than one node, list them like so:
Save and close that file. You can now test this by pinging all of your added nodes with the command:
You should see SUCCESS in the output (Figure C).
Figure C
One thing to note is that Ansible will attempt to connect with the user running the command. So if you issue the Ansible command with user jack, it will attempt to connect to the nodes with that user. If that user isn't on your nodes, you need to instruct Ansible which user to use. To do this, follow these steps:
- Create a new directory (on the Ansible server) with the command sudo mkdir /etc/ansible/group_vars.
- Create a new file with the command sudo nano /etc/ansible/group_vars/servers.
- In that file, add the following line: ansible_ssh_user: USERNAME (Where USERNAME is the username on the remote node).
- Save and close that file.
Congratulations, Ansible is installed and communicating with a node. You're now ready to start creating playbooks.
TechRepublic Premium Exclusives Newsletter
Save time with the latest TechRepublic Premium downloads, including original research, customizable IT policy templates, ready-made lunch-and-learn presentations, IT hiring tools, ROI calculators, and more. Exclusively for you! Delivered Tuesdays and Thursdays
Sign up today Sign up today Also see
- How to make your Linux machines visible to other Linux machines (TechRepublic)
- How to run remote commands on multiple Linux servers with Parallel-SSH (TechRepublic)
- How to monitor network traffic with Linux and vnStat (TechRepublic)
- How to get a job in cloud computing: 10 skills to master (TechRepublic)
- Red Hat Satellite integrated new, improved Ansible DevOps (ZDNet)
- Executive's guide to the software defined data center (TechRepublic download)
- The data center is dead: Here's what comes next (ZDNet)
- Best cloud services for small businesses (CNET)